Transcoder: MediaSampleReader sometimes drops last sample.
A bug caused MSR to drop the last sample in the file if that
was the only sample left to read and another track advanced past
it to make the extractor reach EOS. When the extractor reached EOS
MSR did not update it's position so when the first track came to read
the last sample it looked like the extractor was already positioned
on top of it.
Fixes: 180051221
Test: MediaSampleReaderNDKTests.TestLastSampleBeforeEOS + all unit tests
Change-Id: I7298dc8dcdafb93830cec2a446f68f7a8c878e19
diff --git a/media/libmediatranscoding/transcoder/MediaSampleReaderNDK.cpp b/media/libmediatranscoding/transcoder/MediaSampleReaderNDK.cpp
index 1a6e7ed..8d36e31 100644
--- a/media/libmediatranscoding/transcoder/MediaSampleReaderNDK.cpp
+++ b/media/libmediatranscoding/transcoder/MediaSampleReaderNDK.cpp
@@ -98,6 +98,9 @@
mTrackCursors[mExtractorTrackIndex].next.reset();
}
+ // Update the extractor's sample index even if this track reaches EOS, so that the other tracks
+ // are not given an incorrect extractor position.
+ mExtractorSampleIndex++;
if (!AMediaExtractor_advance(mExtractor)) {
LOG(DEBUG) << " EOS in advanceExtractor_l";
mEosReached = true;
@@ -108,7 +111,6 @@
}
mExtractorTrackIndex = AMediaExtractor_getSampleTrackIndex(mExtractor);
- mExtractorSampleIndex++;
SampleCursor& cursor = mTrackCursors[mExtractorTrackIndex];
if (mExtractorSampleIndex > cursor.previous.index) {