From 1ed048dba80f4b3e2e9e8da8aff4578f2e24b0d1 Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Tue, 23 Sep 2014 11:13:54 +0100 Subject: [PATCH] Clean up TTML timestamp parsing. --- .../android/exoplayer/text/ttml/TtmlParser.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java index 6fdf7d546f..2fd1850f53 100644 --- a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java +++ b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java @@ -233,22 +233,22 @@ public class TtmlParser implements SubtitleParser { matcher = OFFSET_TIME.matcher(time); if (matcher.matches()) { String timeValue = matcher.group(1); - double value = Double.parseDouble(timeValue); + double offsetSeconds = Double.parseDouble(timeValue); String unit = matcher.group(2); if (unit.equals("h")) { - value *= 3600L * 1000000L; + offsetSeconds *= 3600; } else if (unit.equals("m")) { - value *= 60 * 1000000; + offsetSeconds *= 60; } else if (unit.equals("s")) { - value *= 1000000; + // Do nothing. } else if (unit.equals("ms")) { - value *= 1000; + offsetSeconds /= 1000; } else if (unit.equals("f")) { - value = value / frameRate * 1000000; + offsetSeconds /= frameRate; } else if (unit.equals("t")) { - value = value / tickRate * 1000000; + offsetSeconds /= tickRate; } - return (long) value; + return (long) (offsetSeconds * 1000000); } throw new NumberFormatException("Malformed time expression: " + time); }