mirror of
https://github.com/androidx/media.git
synced 2025-05-12 01:59:50 +08:00
Make SsaDecoder more robust against malformed content
Issue: #3645 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=180559196
This commit is contained in:
parent
ad95a147d2
commit
f657893973
@ -150,6 +150,12 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (formatStartIndex == C.INDEX_UNSET
|
||||||
|
|| formatEndIndex == C.INDEX_UNSET
|
||||||
|
|| formatTextIndex == C.INDEX_UNSET) {
|
||||||
|
// Set to 0 so that parseDialogueLine skips lines until a complete format line is found.
|
||||||
|
formatKeyCount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,12 +167,17 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
|
|||||||
*/
|
*/
|
||||||
private void parseDialogueLine(String dialogueLine, List<Cue> cues, LongArray cueTimesUs) {
|
private void parseDialogueLine(String dialogueLine, List<Cue> cues, LongArray cueTimesUs) {
|
||||||
if (formatKeyCount == 0) {
|
if (formatKeyCount == 0) {
|
||||||
Log.w(TAG, "Skipping dialogue line before format: " + dialogueLine);
|
Log.w(TAG, "Skipping dialogue line before complete format: " + dialogueLine);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] lineValues = dialogueLine.substring(DIALOGUE_LINE_PREFIX.length())
|
String[] lineValues = dialogueLine.substring(DIALOGUE_LINE_PREFIX.length())
|
||||||
.split(",", formatKeyCount);
|
.split(",", formatKeyCount);
|
||||||
|
if (lineValues.length != formatKeyCount) {
|
||||||
|
Log.w(TAG, "Skipping dialogue line with fewer columns than format: " + dialogueLine);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long startTimeUs = SsaDecoder.parseTimecodeUs(lineValues[formatStartIndex]);
|
long startTimeUs = SsaDecoder.parseTimecodeUs(lineValues[formatStartIndex]);
|
||||||
if (startTimeUs == C.TIME_UNSET) {
|
if (startTimeUs == C.TIME_UNSET) {
|
||||||
Log.w(TAG, "Skipping invalid timing: " + dialogueLine);
|
Log.w(TAG, "Skipping invalid timing: " + dialogueLine);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user