From f29af879c0458cc429af7c89f157603e2eb819f1 Mon Sep 17 00:00:00 2001 From: kimvde Date: Thu, 6 Aug 2020 13:40:00 +0100 Subject: [PATCH] FragmentedMp4Extractor: allow both first_sample_flags and sample_flags Having both in the trun box is not allowed (see section section 8.8.8.1 of ISO/IEC 14496-12:2015) but this CL makes the code more robust in case this happens. Before this change, the first sample flag was not read, making subsequent reads incorrect. Issue: #7698 PiperOrigin-RevId: 325212160 --- .../exoplayer2/extractor/mp4/FragmentedMp4Extractor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java index ce0ff55acd..3d789b5aba 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java @@ -1011,8 +1011,10 @@ public class FragmentedMp4Extractor implements Extractor { checkNonNegative(sampleDurationsPresent ? trun.readInt() : defaultSampleValues.duration); int sampleSize = checkNonNegative(sampleSizesPresent ? trun.readInt() : defaultSampleValues.size); - int sampleFlags = (i == 0 && firstSampleFlagsPresent) ? firstSampleFlags - : sampleFlagsPresent ? trun.readInt() : defaultSampleValues.flags; + int sampleFlags = + sampleFlagsPresent + ? trun.readInt() + : (i == 0 && firstSampleFlagsPresent) ? firstSampleFlags : defaultSampleValues.flags; if (sampleCompositionTimeOffsetsPresent) { // The BMFF spec (ISO 14496-12) states that sample offsets should be unsigned integers in // version 0 trun boxes, however a significant number of streams violate the spec and use