diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 2483a1954e..a083222f52 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -10,6 +10,9 @@ per sample. * Fix playback hanging on DASH multi-period streams when CEA-608 subtitles are enabled ([#1863](https://github.com/androidx/media/issues/1863)). + * Fix garbled CEA-608 subtitles in MP4 files that incorrectly mark every + sample as a sync sample + ([#1863](https://github.com/androidx/media/issues/1863)). * Demo app * Resolve the memory leaks in demo short-form app ([#1839](https://github.com/androidx/media/issues/1839)). diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java b/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java index db44bc77c6..05e299e104 100644 --- a/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/FragmentedMp4Extractor.java @@ -1637,17 +1637,17 @@ private boolean readSample(ExtractorInput input) throws IOException { : 0); nalBuffer.setLimit(unescapedLength); - if (track.format.maxNumReorderSamples != Format.NO_VALUE - && track.format.maxNumReorderSamples != reorderingSeiMessageQueue.getMaxSize()) { + if (track.format.maxNumReorderSamples == Format.NO_VALUE) { + if (reorderingSeiMessageQueue.getMaxSize() != 0) { + reorderingSeiMessageQueue.setMaxSize(0); + } + } else if (reorderingSeiMessageQueue.getMaxSize() + != track.format.maxNumReorderSamples) { reorderingSeiMessageQueue.setMaxSize(track.format.maxNumReorderSamples); } reorderingSeiMessageQueue.add(sampleTimeUs, nalBuffer); - boolean sampleIsKeyFrameOrEndOfStream = - (trackBundle.getCurrentSampleFlags() - & (C.BUFFER_FLAG_KEY_FRAME | C.BUFFER_FLAG_END_OF_STREAM)) - != 0; - if (sampleIsKeyFrameOrEndOfStream) { + if ((trackBundle.getCurrentSampleFlags() & C.BUFFER_FLAG_END_OF_STREAM) != 0) { reorderingSeiMessageQueue.flush(); } } else {