Commit a56af3d0 by christosts Committed by Oliver Woodman

SubtitleExtractor: mark the limit of the input buffer

Before this change, the SubtitleExtractor did not mark the limit
of the input buffer, thus the SubtitleDecoder attempted to decode
more bytes. If the subtitle file had a new line at the end, this
bug would make the SubtitleDecoder append an line break after the
last subtitle.

PiperOrigin-RevId: 402523039
parent 8a9dcade
......@@ -212,6 +212,7 @@ public class SubtitleExtractor implements Extractor {
}
inputBuffer.ensureSpaceForWrite(bytesRead);
inputBuffer.data.put(subtitleData.getData(), /* offset= */ 0, bytesRead);
inputBuffer.data.limit(bytesRead);
subtitleDecoder.queueInputBuffer(inputBuffer);
@Nullable SubtitleOutputBuffer outputBuffer = subtitleDecoder.dequeueOutputBuffer();
while (outputBuffer == null) {
......
......@@ -44,7 +44,7 @@ public class SubtitleExtractorTest {
+ "This is the second subtitle.\n"
+ "\n"
+ "00:02.600 --> 00:04.567\n"
+ "This is the third subtitle.";
+ "This is the third subtitle.\n";
@Test
public void extractor_outputsCues() throws Exception {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment