mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix subtitle parsing regex suggestions
Suggested by Android Studio's Inspect Code SO seems to think there's a performance difference for the | change: https://stackoverflow.com/questions/22132450/why-is-a-character-class-faster-than-alternation PiperOrigin-RevId: 277707341
This commit is contained in:
parent
5ff7f3a17e
commit
a7b242998a
2 changed files with 8 additions and 7 deletions
|
|
@ -38,8 +38,8 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
|
||||||
|
|
||||||
private static final String TAG = "SsaDecoder";
|
private static final String TAG = "SsaDecoder";
|
||||||
|
|
||||||
private static final Pattern SSA_TIMECODE_PATTERN = Pattern.compile(
|
private static final Pattern SSA_TIMECODE_PATTERN =
|
||||||
"(?:(\\d+):)?(\\d+):(\\d+)(?::|\\.)(\\d+)");
|
Pattern.compile("(?:(\\d+):)?(\\d+):(\\d+)[:.](\\d+)");
|
||||||
private static final String FORMAT_LINE_PREFIX = "Format: ";
|
private static final String FORMAT_LINE_PREFIX = "Format: ";
|
||||||
private static final String DIALOGUE_LINE_PREFIX = "Dialogue: ";
|
private static final String DIALOGUE_LINE_PREFIX = "Dialogue: ";
|
||||||
|
|
||||||
|
|
@ -196,10 +196,11 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String text = lineValues[formatTextIndex]
|
String text =
|
||||||
.replaceAll("\\{.*?\\}", "")
|
lineValues[formatTextIndex]
|
||||||
.replaceAll("\\\\N", "\n")
|
.replaceAll("\\{.*?}", "")
|
||||||
.replaceAll("\\\\n", "\n");
|
.replaceAll("\\\\N", "\n")
|
||||||
|
.replaceAll("\\\\n", "\n");
|
||||||
cues.add(new Cue(text));
|
cues.add(new Cue(text));
|
||||||
cueTimesUs.add(startTimeUs);
|
cueTimesUs.add(startTimeUs);
|
||||||
if (endTimeUs != C.TIME_UNSET) {
|
if (endTimeUs != C.TIME_UNSET) {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import java.util.regex.Pattern;
|
||||||
*/
|
*/
|
||||||
public final class WebvttParserUtil {
|
public final class WebvttParserUtil {
|
||||||
|
|
||||||
private static final Pattern COMMENT = Pattern.compile("^NOTE((\u0020|\u0009).*)?$");
|
private static final Pattern COMMENT = Pattern.compile("^NOTE([ \t].*)?$");
|
||||||
private static final String WEBVTT_HEADER = "WEBVTT";
|
private static final String WEBVTT_HEADER = "WEBVTT";
|
||||||
|
|
||||||
private WebvttParserUtil() {}
|
private WebvttParserUtil() {}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue