SubtitleExtractor: optimize calls to ExtractorInput.read()
When ExtractorInput.getLength() returns a defined length, the SubtitleExtractor will create a buffer of the same length, call ExtractorInput.read() until it has read the input bytes, plus one more time where ExtractorInput.read() returns RESULT_END_OF_INPUT. The last call to ExtractorInput.read() however will make the SubtitleExtractor to increase its buffer (including a copy) unnecessarily. This change makes the SubtitleExtractor avoid calling ExtractorInput.read() if the expected number of bytes have already been read, so that the internal buffer does not grow. PiperOrigin-RevId: 402583610
This commit is contained in:
parent
86162c69b7
commit
a18e281275
@ -199,7 +199,9 @@ public class SubtitleExtractor implements Extractor {
|
||||
if (readResult != C.RESULT_END_OF_INPUT) {
|
||||
bytesRead += readResult;
|
||||
}
|
||||
return readResult == C.RESULT_END_OF_INPUT;
|
||||
long inputLength = input.getLength();
|
||||
return (inputLength != C.LENGTH_UNSET && bytesRead == inputLength)
|
||||
|| readResult == C.RESULT_END_OF_INPUT;
|
||||
}
|
||||
|
||||
/** Decodes the subtitle data and stores the samples in the memory of the extractor. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user