From a67394b2308d1d65a4187f81280b8682d084410c Mon Sep 17 00:00:00 2001 From: ybai001 Date: Mon, 6 Jan 2020 15:21:43 +0800 Subject: [PATCH] Optimize AC-4 code and add related test cases -- Optimize Mp4Extractor for AC-4 -- Optimize FragmentedMp4Extractor for AC-4 -- Add test case for AC-4 in MP4 -- Add test case for AC-4 in Fragmented MP4 --- .../android/exoplayer2/audio/Ac4Util.java | 6 + .../extractor/mp4/FragmentedMp4Extractor.java | 20 ++-- .../extractor/mp4/Mp4Extractor.java | 19 ++-- .../core/src/test/assets/mp4/sample_ac4.mp4 | Bin 0 -> 8238 bytes .../src/test/assets/mp4/sample_ac4.mp4.0.dump | 107 ++++++++++++++++++ .../src/test/assets/mp4/sample_ac4.mp4.1.dump | 107 ++++++++++++++++++ .../src/test/assets/mp4/sample_ac4.mp4.2.dump | 107 ++++++++++++++++++ .../src/test/assets/mp4/sample_ac4.mp4.3.dump | 107 ++++++++++++++++++ .../test/assets/mp4/sample_ac4_fragmented.mp4 | Bin 0 -> 8404 bytes .../mp4/sample_ac4_fragmented.mp4.0.dump | 107 ++++++++++++++++++ .../mp4/sample_ac4_fragmented.mp4.1.dump | 83 ++++++++++++++ .../mp4/sample_ac4_fragmented.mp4.2.dump | 59 ++++++++++ .../mp4/sample_ac4_fragmented.mp4.3.dump | 35 ++++++ .../mp4/FragmentedMp4ExtractorTest.java | 6 + .../extractor/mp4/Mp4ExtractorTest.java | 5 + 15 files changed, 744 insertions(+), 24 deletions(-) create mode 100644 library/core/src/test/assets/mp4/sample_ac4.mp4 create mode 100644 library/core/src/test/assets/mp4/sample_ac4.mp4.0.dump create mode 100644 library/core/src/test/assets/mp4/sample_ac4.mp4.1.dump create mode 100644 library/core/src/test/assets/mp4/sample_ac4.mp4.2.dump create mode 100644 library/core/src/test/assets/mp4/sample_ac4.mp4.3.dump create mode 100644 library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4 create mode 100644 library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.0.dump create mode 100644 library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.1.dump create mode 100644 library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.2.dump create mode 100644 library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.3.dump diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java index c54e3844a3..f3b3a8fc1d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java @@ -57,6 +57,12 @@ public final class Ac4Util { /** The channel count of AC-4 stream. */ // TODO: Parse AC-4 stream channel count. private static final int CHANNEL_COUNT_2 = 2; + /** + * The AC-4 sync frame header size for extractor. + * The 7 bytes are 0xAC, 0x40, 0xFF, 0xFF, sizeByte1, sizeByte2, sizeByte3. + * See ETSI TS 103 190-1 V1.3.1, Annex G + */ + public static final int SAMPLE_HEADER_SIZE = 7; /** * The header size for AC-4 parser. Only needs to be as big as we need to read, not the full * header size. diff --git a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java index 1172f8665a..967f71b328 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java @@ -168,7 +168,6 @@ public class FragmentedMp4Extractor implements Extractor { private int sampleBytesWritten; private int sampleCurrentNalBytesRemaining; private boolean processSeiNalUnitPayload; - private boolean isAc4HeaderRequired; // Extractor output. @MonotonicNonNull private ExtractorOutput extractorOutput; @@ -302,7 +301,6 @@ public class FragmentedMp4Extractor implements Extractor { pendingMetadataSampleBytes = 0; pendingSeekTimeUs = timeUs; containerAtoms.clear(); - isAc4HeaderRequired = false; enterReadingAtomHeaderState(); } @@ -1267,12 +1265,18 @@ public class FragmentedMp4Extractor implements Extractor { sampleSize -= Atom.HEADER_SIZE; input.skipFully(Atom.HEADER_SIZE); } + boolean isAc4HeaderRequired = + MimeTypes.AUDIO_AC4.equals(currentTrackBundle.track.format.sampleMimeType); sampleBytesWritten = currentTrackBundle.outputSampleEncryptionData(); sampleSize += sampleBytesWritten; + if (isAc4HeaderRequired) { + Ac4Util.getAc4SampleHeader(sampleSize, scratch); + currentTrackBundle.output.sampleData(scratch, Ac4Util.SAMPLE_HEADER_SIZE); + sampleBytesWritten += Ac4Util.SAMPLE_HEADER_SIZE; + sampleSize += Ac4Util.SAMPLE_HEADER_SIZE; + } parserState = STATE_READING_SAMPLE_CONTINUE; sampleCurrentNalBytesRemaining = 0; - isAc4HeaderRequired = - MimeTypes.AUDIO_AC4.equals(currentTrackBundle.track.format.sampleMimeType); } TrackFragment fragment = currentTrackBundle.fragment; @@ -1337,14 +1341,6 @@ public class FragmentedMp4Extractor implements Extractor { } } } else { - if (isAc4HeaderRequired) { - Ac4Util.getAc4SampleHeader(sampleSize, scratch); - int length = scratch.limit(); - output.sampleData(scratch, length); - sampleSize += length; - sampleBytesWritten += length; - isAc4HeaderRequired = false; - } while (sampleBytesWritten < sampleSize) { int writtenBytes = output.sampleData(input, sampleSize - sampleBytesWritten, false); sampleBytesWritten += writtenBytes; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java index 971cc27d13..651db26b5e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java @@ -112,7 +112,6 @@ public final class Mp4Extractor implements Extractor, SeekMap { private int sampleTrackIndex; private int sampleBytesWritten; private int sampleCurrentNalBytesRemaining; - private boolean isAc4HeaderRequired; // Extractor outputs. @MonotonicNonNull private ExtractorOutput extractorOutput; @@ -162,7 +161,6 @@ public final class Mp4Extractor implements Extractor, SeekMap { sampleTrackIndex = C.INDEX_UNSET; sampleBytesWritten = 0; sampleCurrentNalBytesRemaining = 0; - isAc4HeaderRequired = false; if (position == 0) { enterReadingAtomHeaderState(); } else if (tracks != null) { @@ -507,8 +505,6 @@ public final class Mp4Extractor implements Extractor, SeekMap { if (sampleTrackIndex == C.INDEX_UNSET) { return RESULT_END_OF_INPUT; } - isAc4HeaderRequired = - MimeTypes.AUDIO_AC4.equals(tracks[sampleTrackIndex].track.format.sampleMimeType); } Mp4Track track = tracks[sampleTrackIndex]; TrackOutput trackOutput = track.trackOutput; @@ -527,6 +523,13 @@ public final class Mp4Extractor implements Extractor, SeekMap { sampleSize -= Atom.HEADER_SIZE; } input.skipFully((int) skipAmount); + if (MimeTypes.AUDIO_AC4.equals(track.track.format.sampleMimeType)) { + Ac4Util.getAc4SampleHeader(sampleSize, scratch); + int length = scratch.limit(); + trackOutput.sampleData(scratch, length); + sampleSize += length; + sampleBytesWritten += length; + } if (track.track.nalUnitLengthFieldLength != 0) { // Zero the top three bytes of the array that we'll use to decode nal unit lengths, in case // they're only 1 or 2 bytes long. @@ -562,14 +565,6 @@ public final class Mp4Extractor implements Extractor, SeekMap { } } } else { - if (isAc4HeaderRequired) { - Ac4Util.getAc4SampleHeader(sampleSize, scratch); - int length = scratch.limit(); - trackOutput.sampleData(scratch, length); - sampleSize += length; - sampleBytesWritten += length; - isAc4HeaderRequired = false; - } while (sampleBytesWritten < sampleSize) { int writtenBytes = trackOutput.sampleData(input, sampleSize - sampleBytesWritten, false); sampleBytesWritten += writtenBytes; diff --git a/library/core/src/test/assets/mp4/sample_ac4.mp4 b/library/core/src/test/assets/mp4/sample_ac4.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..d649632c745ef055934dda90e750e1b99f991593 GIT binary patch literal 8238 zcmeHMc{r6_*S}36PLElMDDzAXk1;1xND_`AGM-~Tren%@l7z>Usgxp*!Vxl8#zLer zlSrsY9b?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?TC-=Rx0%R_ zZSr)1wkFJx$DMLt#KycmUXYhGdou|gaW>m+IXGhNZX*EzHWN=aI)zoAY}|(T#5n|9 zV?}rN#NlBW<^o&CdH9m|Gr%R|5@|Q^hS6d-OV&(ibLQ0m(lw)u38`K;kC7P78iJ!< z5Le~pBMMJ7`+Z}q(}ZwXhX5g?Q7)2yLZK&^{f1{ldZc7=KU3!Iob>79T$@uTEUTp2 z3{n>3Lv#%gn@*n}&LP>Xuu`@{g0*YYUUgd90BU@5vYVC zaL3kh^=kwUowV=INT&KulxkkKH zmP68Y4Bjg*kd#eK+Tu8jYJEeOmwrCCv9?izxtiK?V24$n(X}nu`?<%6VImKsa$pC z%}S9M%T@BOloac*DrDhKGo$EZ@(ZE8CJ|QJ}_^1zt=&t%XV>SWb0!fJoP?vw<_O;k)6^%2}Rz z$9Fv_@FqxV&z3AQ*4(!pv7RVa+LQxq@hb!keMxvp_z*bp9qw-lkHzRQBpYzm7^I1^ z947ViP8}MHB2%fK=!%G)^yHE2D-XT6P#-A@CM}HVC8+vMnn|5GdYzh(^M{Z7?dVS? zR^-%23}wj16t_mRxr<_?stS&wgqY%Z?Yv<(rTY&LRy)r0(O<8%Ew#lBkW_l0cM>XUpP5;hPl zky>Lj?!6;KO9ev`+A774w0uYnh~pO4zV}G}p?i}TqqOY% b-oeDizO2Xc2Qp{?8omZ)=pUE=<}UId;b<$Z literal 0 HcmV?d00001 diff --git a/library/core/src/test/assets/mp4/sample_ac4.mp4.0.dump b/library/core/src/test/assets/mp4/sample_ac4.mp4.0.dump new file mode 100644 index 0000000000..92ba157e3f --- /dev/null +++ b/library/core/src/test/assets/mp4/sample_ac4.mp4.0.dump @@ -0,0 +1,107 @@ +seekMap: + isSeekable = true + duration = 760000 + getPosition(0) = [[timeUs=0, position=758]] +numberOfTracks = 1 +track 0: + format: + bitrate = -1 + id = 1 + containerMimeType = null + sampleMimeType = audio/ac4 + maxInputSize = 622 + width = -1 + height = -1 + frameRate = -1.0 + rotationDegrees = 0 + pixelWidthHeightRatio = 1.0 + channelCount = 2 + sampleRate = 48000 + pcmEncoding = -1 + encoderDelay = 0 + encoderPadding = 0 + subsampleOffsetUs = 9223372036854775807 + selectionFlags = 0 + language = und + drmInitData = - + metadata = null + initializationData: + total output bytes = 7613 + sample count = 19 + sample 0: + time = 0 + flags = 1 + data = length 367, hash D2762FA + sample 1: + time = 40000 + flags = 0 + data = length 367, hash BDD3224A + sample 2: + time = 80000 + flags = 0 + data = length 367, hash 9302227B + sample 3: + time = 120000 + flags = 0 + data = length 367, hash 72996003 + sample 4: + time = 160000 + flags = 0 + data = length 367, hash 88AE5A1B + sample 5: + time = 200000 + flags = 0 + data = length 367, hash E5346FE3 + sample 6: + time = 240000 + flags = 0 + data = length 367, hash CE558362 + sample 7: + time = 280000 + flags = 0 + data = length 367, hash 51AD3043 + sample 8: + time = 320000 + flags = 0 + data = length 367, hash EB72E95B + sample 9: + time = 360000 + flags = 0 + data = length 367, hash 47F8FF23 + sample 10: + time = 400000 + flags = 0 + data = length 367, hash 8133883D + sample 11: + time = 440000 + flags = 0 + data = length 495, hash E14BDFEE + sample 12: + time = 480000 + flags = 0 + data = length 520, hash FEE56928 + sample 13: + time = 519999 + flags = 0 + data = length 599, hash 41F496C5 + sample 14: + time = 560000 + flags = 0 + data = length 436, hash 76D6404 + sample 15: + time = 600000 + flags = 0 + data = length 366, hash 56D49D4D + sample 16: + time = 640000 + flags = 0 + data = length 393, hash 822FC8 + sample 17: + time = 680000 + flags = 0 + data = length 374, hash FA8AE217 + sample 18: + time = 720000 + flags = 536870912 + data = length 393, hash 8506A1B +tracksEnded = true diff --git a/library/core/src/test/assets/mp4/sample_ac4.mp4.1.dump b/library/core/src/test/assets/mp4/sample_ac4.mp4.1.dump new file mode 100644 index 0000000000..92ba157e3f --- /dev/null +++ b/library/core/src/test/assets/mp4/sample_ac4.mp4.1.dump @@ -0,0 +1,107 @@ +seekMap: + isSeekable = true + duration = 760000 + getPosition(0) = [[timeUs=0, position=758]] +numberOfTracks = 1 +track 0: + format: + bitrate = -1 + id = 1 + containerMimeType = null + sampleMimeType = audio/ac4 + maxInputSize = 622 + width = -1 + height = -1 + frameRate = -1.0 + rotationDegrees = 0 + pixelWidthHeightRatio = 1.0 + channelCount = 2 + sampleRate = 48000 + pcmEncoding = -1 + encoderDelay = 0 + encoderPadding = 0 + subsampleOffsetUs = 9223372036854775807 + selectionFlags = 0 + language = und + drmInitData = - + metadata = null + initializationData: + total output bytes = 7613 + sample count = 19 + sample 0: + time = 0 + flags = 1 + data = length 367, hash D2762FA + sample 1: + time = 40000 + flags = 0 + data = length 367, hash BDD3224A + sample 2: + time = 80000 + flags = 0 + data = length 367, hash 9302227B + sample 3: + time = 120000 + flags = 0 + data = length 367, hash 72996003 + sample 4: + time = 160000 + flags = 0 + data = length 367, hash 88AE5A1B + sample 5: + time = 200000 + flags = 0 + data = length 367, hash E5346FE3 + sample 6: + time = 240000 + flags = 0 + data = length 367, hash CE558362 + sample 7: + time = 280000 + flags = 0 + data = length 367, hash 51AD3043 + sample 8: + time = 320000 + flags = 0 + data = length 367, hash EB72E95B + sample 9: + time = 360000 + flags = 0 + data = length 367, hash 47F8FF23 + sample 10: + time = 400000 + flags = 0 + data = length 367, hash 8133883D + sample 11: + time = 440000 + flags = 0 + data = length 495, hash E14BDFEE + sample 12: + time = 480000 + flags = 0 + data = length 520, hash FEE56928 + sample 13: + time = 519999 + flags = 0 + data = length 599, hash 41F496C5 + sample 14: + time = 560000 + flags = 0 + data = length 436, hash 76D6404 + sample 15: + time = 600000 + flags = 0 + data = length 366, hash 56D49D4D + sample 16: + time = 640000 + flags = 0 + data = length 393, hash 822FC8 + sample 17: + time = 680000 + flags = 0 + data = length 374, hash FA8AE217 + sample 18: + time = 720000 + flags = 536870912 + data = length 393, hash 8506A1B +tracksEnded = true diff --git a/library/core/src/test/assets/mp4/sample_ac4.mp4.2.dump b/library/core/src/test/assets/mp4/sample_ac4.mp4.2.dump new file mode 100644 index 0000000000..92ba157e3f --- /dev/null +++ b/library/core/src/test/assets/mp4/sample_ac4.mp4.2.dump @@ -0,0 +1,107 @@ +seekMap: + isSeekable = true + duration = 760000 + getPosition(0) = [[timeUs=0, position=758]] +numberOfTracks = 1 +track 0: + format: + bitrate = -1 + id = 1 + containerMimeType = null + sampleMimeType = audio/ac4 + maxInputSize = 622 + width = -1 + height = -1 + frameRate = -1.0 + rotationDegrees = 0 + pixelWidthHeightRatio = 1.0 + channelCount = 2 + sampleRate = 48000 + pcmEncoding = -1 + encoderDelay = 0 + encoderPadding = 0 + subsampleOffsetUs = 9223372036854775807 + selectionFlags = 0 + language = und + drmInitData = - + metadata = null + initializationData: + total output bytes = 7613 + sample count = 19 + sample 0: + time = 0 + flags = 1 + data = length 367, hash D2762FA + sample 1: + time = 40000 + flags = 0 + data = length 367, hash BDD3224A + sample 2: + time = 80000 + flags = 0 + data = length 367, hash 9302227B + sample 3: + time = 120000 + flags = 0 + data = length 367, hash 72996003 + sample 4: + time = 160000 + flags = 0 + data = length 367, hash 88AE5A1B + sample 5: + time = 200000 + flags = 0 + data = length 367, hash E5346FE3 + sample 6: + time = 240000 + flags = 0 + data = length 367, hash CE558362 + sample 7: + time = 280000 + flags = 0 + data = length 367, hash 51AD3043 + sample 8: + time = 320000 + flags = 0 + data = length 367, hash EB72E95B + sample 9: + time = 360000 + flags = 0 + data = length 367, hash 47F8FF23 + sample 10: + time = 400000 + flags = 0 + data = length 367, hash 8133883D + sample 11: + time = 440000 + flags = 0 + data = length 495, hash E14BDFEE + sample 12: + time = 480000 + flags = 0 + data = length 520, hash FEE56928 + sample 13: + time = 519999 + flags = 0 + data = length 599, hash 41F496C5 + sample 14: + time = 560000 + flags = 0 + data = length 436, hash 76D6404 + sample 15: + time = 600000 + flags = 0 + data = length 366, hash 56D49D4D + sample 16: + time = 640000 + flags = 0 + data = length 393, hash 822FC8 + sample 17: + time = 680000 + flags = 0 + data = length 374, hash FA8AE217 + sample 18: + time = 720000 + flags = 536870912 + data = length 393, hash 8506A1B +tracksEnded = true diff --git a/library/core/src/test/assets/mp4/sample_ac4.mp4.3.dump b/library/core/src/test/assets/mp4/sample_ac4.mp4.3.dump new file mode 100644 index 0000000000..92ba157e3f --- /dev/null +++ b/library/core/src/test/assets/mp4/sample_ac4.mp4.3.dump @@ -0,0 +1,107 @@ +seekMap: + isSeekable = true + duration = 760000 + getPosition(0) = [[timeUs=0, position=758]] +numberOfTracks = 1 +track 0: + format: + bitrate = -1 + id = 1 + containerMimeType = null + sampleMimeType = audio/ac4 + maxInputSize = 622 + width = -1 + height = -1 + frameRate = -1.0 + rotationDegrees = 0 + pixelWidthHeightRatio = 1.0 + channelCount = 2 + sampleRate = 48000 + pcmEncoding = -1 + encoderDelay = 0 + encoderPadding = 0 + subsampleOffsetUs = 9223372036854775807 + selectionFlags = 0 + language = und + drmInitData = - + metadata = null + initializationData: + total output bytes = 7613 + sample count = 19 + sample 0: + time = 0 + flags = 1 + data = length 367, hash D2762FA + sample 1: + time = 40000 + flags = 0 + data = length 367, hash BDD3224A + sample 2: + time = 80000 + flags = 0 + data = length 367, hash 9302227B + sample 3: + time = 120000 + flags = 0 + data = length 367, hash 72996003 + sample 4: + time = 160000 + flags = 0 + data = length 367, hash 88AE5A1B + sample 5: + time = 200000 + flags = 0 + data = length 367, hash E5346FE3 + sample 6: + time = 240000 + flags = 0 + data = length 367, hash CE558362 + sample 7: + time = 280000 + flags = 0 + data = length 367, hash 51AD3043 + sample 8: + time = 320000 + flags = 0 + data = length 367, hash EB72E95B + sample 9: + time = 360000 + flags = 0 + data = length 367, hash 47F8FF23 + sample 10: + time = 400000 + flags = 0 + data = length 367, hash 8133883D + sample 11: + time = 440000 + flags = 0 + data = length 495, hash E14BDFEE + sample 12: + time = 480000 + flags = 0 + data = length 520, hash FEE56928 + sample 13: + time = 519999 + flags = 0 + data = length 599, hash 41F496C5 + sample 14: + time = 560000 + flags = 0 + data = length 436, hash 76D6404 + sample 15: + time = 600000 + flags = 0 + data = length 366, hash 56D49D4D + sample 16: + time = 640000 + flags = 0 + data = length 393, hash 822FC8 + sample 17: + time = 680000 + flags = 0 + data = length 374, hash FA8AE217 + sample 18: + time = 720000 + flags = 536870912 + data = length 393, hash 8506A1B +tracksEnded = true diff --git a/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4 b/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..2056348768808517cbbf07c417c230d701eb9d35 GIT binary patch literal 8404 zcmeHMc|29y+ushNI9;=wh%!$hhigb?AxSufDAPISV>ss+%5;*1YsyqgQCH!JGFON~ zq%u>HP?f(Zzu>QsKY%X-pLDUwkLXRjLGyD(XZN|asNz+4d!>_{Lkakp>Y@wCrE`5 z4)bMQf2yk{!DV#g21m&q4WA;Qm3m2<8i)AA`rj?Qnvp%^HCB7W!JQArPItp|T%=NZ0`UE8o${MHU5>;q>QH z5da&^_%dZ+KgP)gC6tTMf>?qOmcs}RDhZkTnT~aq;~NPX!l<4TkwR?B=>R3?)RwZ}4GJcH<>$kVs1YQojW`K6`ohByzZ(=o z#0U7$0SHE@ofFFC2)J-Mgb-4| zh2av0)SKu$li zA%?@uQMsR7=t=HHqj42zt6nsjOdjwg7m*9mXmn*S+74|+Cg*QV{y+Lb+Vvj7S)ar^ ztN`H*$nUaefV|-#kYh$S3a672^E z{SWL;Iv@h!Z1ByW`M<~6@IMfgf5VbVrkJ1p{BOYZdzGXUFwQ^y`FmXcuj?cqI6e!1 zi_fNT+~9}LK_CZ!Uf1W~0e{BmABLS2{xd%RFo=Ic0V(lkeEu6S{jdn>>d*N6!yx_* z1*Bp)K8t>PuPgrYUWeHHPJv?c9|$C8G>b^3$xbWIfkrJwj%ljX4$)G_%9fSx{)tXA z)JWu$ZBM#N5qu`8&A{>Tktj^YlN-*@1@-(H^k+K+ycc5~oPQPl8tzOg|WAgCPDC z*iII0P}99%hYvlcqCx<{^^65)E-lSs&Q^zo%v*86TWj01W?9<=&ty=989_4n4kn^y zgtx^>K9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)>5AqtGBYi%u3J?AyXLvu z8+leyX3ci#gxiFd5^+j3=3$FE8A-870G4BrL=O#^GOF~DS%=Y|rDuQ~ajsyU!iAU;O!zz!|t;2ibG!l-nlAC*CUq1|U zzJtpwe8>A4;FEWcbnJc0YO{?aYbvxM^HLz?vRTH+-Y!q?ff(H?l8aF=U-^Xt%1?EB z@GjCUzhBX7smNV$r}#BNj20_Cs;ZaKIteX+pq z!&-VA$!0Qq_jMQ?Nj@G2^Bg|Dm;I&j;9|kF+X}xZTkJql+v%!4z5!qLPa)|BCgW;z z6g3Nr<~Sa+YJ3Q-yxDd|vcm9lf=@z=lY`q}dGlK1X#Xq0%6bu&fVE0nK3&ff1^bc7 z9i6zg_y>doql>l)rJnwZsa2~fgvZnG7P*^GHtP2FX=mfE)t;3|12c{UuFcnhXdp}z zTnOhmkY@v!h~(r)MjkVdConMgi5dHRbYHvTdw#v;;Bj^Nk!KU{)h~GnW~C@eU03xh zmz8R@E8yTyv!d%}BZe?t7KtsJ@#n5+`Ym-31jS>0-aehlvzx4;d=hkTbj9s!H7^_Q z6R$jGqD0uQgyO#OC`jkxoFJx_$ws{nETzBGOJ?peSixCW30?K#{tA@VMRV7IDHM>qvw z=P^)b>yY-=*K*<%zWI4^ar!s?-{+qfhcbK472)-k?}?qD)+YHsB&{GhBK3x*yt)R+ zx`K9%W@pkgd}Uw84S+>uW9*)XMDI4(w?vjKAKcSNwLO#VFz}K+vn9zvh_TePv`={@q7P554MrS>+VQyZRFAy0acD z?aE*T7=<3FK|e14^28nL|idO$GP`*QP literal 0 HcmV?d00001 diff --git a/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.0.dump b/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.0.dump new file mode 100644 index 0000000000..505c85e51f --- /dev/null +++ b/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.0.dump @@ -0,0 +1,107 @@ +seekMap: + isSeekable = true + duration = 760000 + getPosition(0) = [[timeUs=0, position=685]] +numberOfTracks = 1 +track 0: + format: + bitrate = -1 + id = 1 + containerMimeType = null + sampleMimeType = audio/ac4 + maxInputSize = -1 + width = -1 + height = -1 + frameRate = -1.0 + rotationDegrees = 0 + pixelWidthHeightRatio = 1.0 + channelCount = 2 + sampleRate = 48000 + pcmEncoding = -1 + encoderDelay = 0 + encoderPadding = 0 + subsampleOffsetUs = 9223372036854775807 + selectionFlags = 0 + language = und + drmInitData = - + metadata = null + initializationData: + total output bytes = 7613 + sample count = 19 + sample 0: + time = 0 + flags = 1 + data = length 367, hash D2762FA + sample 1: + time = 40000 + flags = 1 + data = length 367, hash BDD3224A + sample 2: + time = 80000 + flags = 1 + data = length 367, hash 9302227B + sample 3: + time = 120000 + flags = 1 + data = length 367, hash 72996003 + sample 4: + time = 160000 + flags = 1 + data = length 367, hash 88AE5A1B + sample 5: + time = 200000 + flags = 1 + data = length 367, hash E5346FE3 + sample 6: + time = 240000 + flags = 1 + data = length 367, hash CE558362 + sample 7: + time = 280000 + flags = 1 + data = length 367, hash 51AD3043 + sample 8: + time = 320000 + flags = 1 + data = length 367, hash EB72E95B + sample 9: + time = 360000 + flags = 1 + data = length 367, hash 47F8FF23 + sample 10: + time = 400000 + flags = 1 + data = length 367, hash 8133883D + sample 11: + time = 440000 + flags = 1 + data = length 495, hash E14BDFEE + sample 12: + time = 480000 + flags = 1 + data = length 520, hash FEE56928 + sample 13: + time = 520000 + flags = 1 + data = length 599, hash 41F496C5 + sample 14: + time = 560000 + flags = 1 + data = length 436, hash 76D6404 + sample 15: + time = 600000 + flags = 1 + data = length 366, hash 56D49D4D + sample 16: + time = 640000 + flags = 1 + data = length 393, hash 822FC8 + sample 17: + time = 680000 + flags = 1 + data = length 374, hash FA8AE217 + sample 18: + time = 720000 + flags = 1 + data = length 393, hash 8506A1B +tracksEnded = true diff --git a/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.1.dump b/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.1.dump new file mode 100644 index 0000000000..8bee343bd9 --- /dev/null +++ b/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.1.dump @@ -0,0 +1,83 @@ +seekMap: + isSeekable = true + duration = 760000 + getPosition(0) = [[timeUs=0, position=685]] +numberOfTracks = 1 +track 0: + format: + bitrate = -1 + id = 1 + containerMimeType = null + sampleMimeType = audio/ac4 + maxInputSize = -1 + width = -1 + height = -1 + frameRate = -1.0 + rotationDegrees = 0 + pixelWidthHeightRatio = 1.0 + channelCount = 2 + sampleRate = 48000 + pcmEncoding = -1 + encoderDelay = 0 + encoderPadding = 0 + subsampleOffsetUs = 9223372036854775807 + selectionFlags = 0 + language = und + drmInitData = - + metadata = null + initializationData: + total output bytes = 5411 + sample count = 13 + sample 0: + time = 240000 + flags = 1 + data = length 367, hash CE558362 + sample 1: + time = 280000 + flags = 1 + data = length 367, hash 51AD3043 + sample 2: + time = 320000 + flags = 1 + data = length 367, hash EB72E95B + sample 3: + time = 360000 + flags = 1 + data = length 367, hash 47F8FF23 + sample 4: + time = 400000 + flags = 1 + data = length 367, hash 8133883D + sample 5: + time = 440000 + flags = 1 + data = length 495, hash E14BDFEE + sample 6: + time = 480000 + flags = 1 + data = length 520, hash FEE56928 + sample 7: + time = 520000 + flags = 1 + data = length 599, hash 41F496C5 + sample 8: + time = 560000 + flags = 1 + data = length 436, hash 76D6404 + sample 9: + time = 600000 + flags = 1 + data = length 366, hash 56D49D4D + sample 10: + time = 640000 + flags = 1 + data = length 393, hash 822FC8 + sample 11: + time = 680000 + flags = 1 + data = length 374, hash FA8AE217 + sample 12: + time = 720000 + flags = 1 + data = length 393, hash 8506A1B +tracksEnded = true diff --git a/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.2.dump b/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.2.dump new file mode 100644 index 0000000000..ee1cf91a57 --- /dev/null +++ b/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.2.dump @@ -0,0 +1,59 @@ +seekMap: + isSeekable = true + duration = 760000 + getPosition(0) = [[timeUs=0, position=685]] +numberOfTracks = 1 +track 0: + format: + bitrate = -1 + id = 1 + containerMimeType = null + sampleMimeType = audio/ac4 + maxInputSize = -1 + width = -1 + height = -1 + frameRate = -1.0 + rotationDegrees = 0 + pixelWidthHeightRatio = 1.0 + channelCount = 2 + sampleRate = 48000 + pcmEncoding = -1 + encoderDelay = 0 + encoderPadding = 0 + subsampleOffsetUs = 9223372036854775807 + selectionFlags = 0 + language = und + drmInitData = - + metadata = null + initializationData: + total output bytes = 3081 + sample count = 7 + sample 0: + time = 480000 + flags = 1 + data = length 520, hash FEE56928 + sample 1: + time = 520000 + flags = 1 + data = length 599, hash 41F496C5 + sample 2: + time = 560000 + flags = 1 + data = length 436, hash 76D6404 + sample 3: + time = 600000 + flags = 1 + data = length 366, hash 56D49D4D + sample 4: + time = 640000 + flags = 1 + data = length 393, hash 822FC8 + sample 5: + time = 680000 + flags = 1 + data = length 374, hash FA8AE217 + sample 6: + time = 720000 + flags = 1 + data = length 393, hash 8506A1B +tracksEnded = true diff --git a/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.3.dump b/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.3.dump new file mode 100644 index 0000000000..419f0444bf --- /dev/null +++ b/library/core/src/test/assets/mp4/sample_ac4_fragmented.mp4.3.dump @@ -0,0 +1,35 @@ +seekMap: + isSeekable = true + duration = 760000 + getPosition(0) = [[timeUs=0, position=685]] +numberOfTracks = 1 +track 0: + format: + bitrate = -1 + id = 1 + containerMimeType = null + sampleMimeType = audio/ac4 + maxInputSize = -1 + width = -1 + height = -1 + frameRate = -1.0 + rotationDegrees = 0 + pixelWidthHeightRatio = 1.0 + channelCount = 2 + sampleRate = 48000 + pcmEncoding = -1 + encoderDelay = 0 + encoderPadding = 0 + subsampleOffsetUs = 9223372036854775807 + selectionFlags = 0 + language = und + drmInitData = - + metadata = null + initializationData: + total output bytes = 393 + sample count = 1 + sample 0: + time = 720000 + flags = 1 + data = length 393, hash 8506A1B +tracksEnded = true diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java index a29dfcc310..1f49aee293 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java @@ -51,6 +51,12 @@ public final class FragmentedMp4ExtractorTest { ExtractorAsserts.assertBehavior(extractorFactory, "mp4/sample_fragmented_sei.mp4"); } + @Test + public void testSampleWithAc4Track() throws Exception { + ExtractorAsserts.assertBehavior( + getExtractorFactory(Collections.emptyList()), "mp4/sample_ac4_fragmented.mp4"); + } + private static ExtractorFactory getExtractorFactory(final List closedCaptionFormats) { return () -> new FragmentedMp4Extractor(0, null, null, null, closedCaptionFormats); } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/Mp4ExtractorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/Mp4ExtractorTest.java index b5c3b26a23..6ddc74c797 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/Mp4ExtractorTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/Mp4ExtractorTest.java @@ -42,4 +42,9 @@ public final class Mp4ExtractorTest { public void testMp4SampleWithMdatTooLong() throws Exception { ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_mdat_too_long.mp4"); } + + @Test + public void testMp4SampleWithAc4Track() throws Exception { + ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac4.mp4"); + } }