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
This commit is contained in:
parent
8a9dcadef3
commit
a56af3d0e0
@ -212,6 +212,7 @@ public class SubtitleExtractor implements Extractor {
|
|||||||
}
|
}
|
||||||
inputBuffer.ensureSpaceForWrite(bytesRead);
|
inputBuffer.ensureSpaceForWrite(bytesRead);
|
||||||
inputBuffer.data.put(subtitleData.getData(), /* offset= */ 0, bytesRead);
|
inputBuffer.data.put(subtitleData.getData(), /* offset= */ 0, bytesRead);
|
||||||
|
inputBuffer.data.limit(bytesRead);
|
||||||
subtitleDecoder.queueInputBuffer(inputBuffer);
|
subtitleDecoder.queueInputBuffer(inputBuffer);
|
||||||
@Nullable SubtitleOutputBuffer outputBuffer = subtitleDecoder.dequeueOutputBuffer();
|
@Nullable SubtitleOutputBuffer outputBuffer = subtitleDecoder.dequeueOutputBuffer();
|
||||||
while (outputBuffer == null) {
|
while (outputBuffer == null) {
|
||||||
|
@ -44,7 +44,7 @@ public class SubtitleExtractorTest {
|
|||||||
+ "This is the second subtitle.\n"
|
+ "This is the second subtitle.\n"
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ "00:02.600 --> 00:04.567\n"
|
+ "00:02.600 --> 00:04.567\n"
|
||||||
+ "This is the third subtitle.";
|
+ "This is the third subtitle.\n";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void extractor_outputsCues() throws Exception {
|
public void extractor_outputsCues() throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user