diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/Mp4Extractor.java b/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/Mp4Extractor.java index 2a221b78a3..b1ea9d81bf 100644 --- a/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/Mp4Extractor.java +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/mp4/Mp4Extractor.java @@ -894,38 +894,48 @@ public final class Mp4Extractor implements Extractor, SeekMap { nalPrefixData[0] = 0; nalPrefixData[1] = 0; nalPrefixData[2] = 0; - int nalUnitPrefixLength = track.track.nalUnitLengthFieldLength + 1; int nalUnitLengthFieldLengthDiff = 4 - track.track.nalUnitLengthFieldLength; // NAL units are length delimited, but the decoder requires start code delimited units. // Loop until we've written the sample to the track output, replacing length delimiters with // start codes as we encounter them. while (sampleBytesWritten < sampleSize) { if (sampleCurrentNalBytesRemaining == 0) { + int nalUnitPrefixLength = track.track.nalUnitLengthFieldLength; + boolean readNalType = false; + if (!isSampleDependedOn + && nalUnitPrefixLength + 1 + <= track.sampleTable.sizes[sampleIndex] - sampleBytesRead) { + // Parsing sample dependencies needs the first NAL unit byte. Read it in the same + // readFully call that reads the NAL length. This ensures sampleBytesRead, + // sampleBytesWritten and isSampleDependedOn remain in a consistent state if we have + // read failures. + nalUnitPrefixLength = track.track.nalUnitLengthFieldLength + 1; + readNalType = true; + } // Read the NAL length so that we know where we find the next one. - // In the same readFully call, read the first payload byte in order to determine - // sample dependencies. Do not attempt to peek the first payload byte because that might - // fail, and we should keep sampleBytesRead, sampleBytesWritten, isSampleDependedOn in - // a consistent state. input.readFully(nalPrefixData, nalUnitLengthFieldLengthDiff, nalUnitPrefixLength); sampleBytesRead += nalUnitPrefixLength; nalPrefix.setPosition(0); int nalLengthInt = nalPrefix.readInt(); - if (nalLengthInt < 1) { + if (nalLengthInt < 0) { throw ParserException.createForMalformedContainer( "Invalid NAL length", /* cause= */ null); } - sampleCurrentNalBytesRemaining = nalLengthInt - 1; + sampleCurrentNalBytesRemaining = nalLengthInt - (readNalType ? 1 : 0); // Write a start code for the current NAL unit. nalStartCode.setPosition(0); trackOutput.sampleData(nalStartCode, 4); - // Write the NAL unit type byte. - trackOutput.sampleData(nalPrefix, 1); - sampleBytesWritten += 5; + sampleBytesWritten += 4; sampleSize += nalUnitLengthFieldLengthDiff; - // If any NAL unit that's part of this sample can be depended on, treat the entire sample - // as depended on. - if (!isSampleDependedOn && NalUnitUtil.isH264NalUnitDependedOn(nalPrefixData[4])) { - isSampleDependedOn = true; + if (readNalType) { + // Write the NAL unit type byte. + trackOutput.sampleData(nalPrefix, 1); + sampleBytesWritten += 1; + // If any NAL unit that's part of this sample can be depended on, treat the entire + // sample as depended on. + if (NalUnitUtil.isH264NalUnitDependedOn(nalPrefixData[4])) { + isSampleDependedOn = true; + } } } else { // Write the payload of the NAL unit. diff --git a/libraries/extractor/src/test/java/androidx/media3/extractor/mp4/Mp4ExtractorParameterizedTest.java b/libraries/extractor/src/test/java/androidx/media3/extractor/mp4/Mp4ExtractorParameterizedTest.java index 3a24611639..427be2b6b0 100644 --- a/libraries/extractor/src/test/java/androidx/media3/extractor/mp4/Mp4ExtractorParameterizedTest.java +++ b/libraries/extractor/src/test/java/androidx/media3/extractor/mp4/Mp4ExtractorParameterizedTest.java @@ -239,6 +239,11 @@ public final class Mp4ExtractorParameterizedTest { "media/mp4/sample_with_fake_auxiliary_tracks_interleaved_with_primary_video_tracks.mp4"); } + @Test + public void mp4SampleWithEmptyNalu() throws Exception { + assertExtractorBehavior("media/mp4/sample_with_invalid_nalu.mp4"); + } + private void assertExtractorBehavior(String file) throws IOException { ExtractorAsserts.AssertionConfig.Builder assertionConfigBuilder = new ExtractorAsserts.AssertionConfig.Builder(); diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.0.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.0.dump new file mode 100644 index 0000000000..a73a901d33 --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.0.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 0 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 0 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 0 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 0 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 0 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 0 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 0 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 0 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 0 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 0 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 0 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 0 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 0 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 536870912 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.1.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.1.dump new file mode 100644 index 0000000000..a73a901d33 --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.1.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 0 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 0 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 0 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 0 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 0 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 0 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 0 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 0 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 0 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 0 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 0 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 0 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 0 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 536870912 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.2.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.2.dump new file mode 100644 index 0000000000..a73a901d33 --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.2.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 0 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 0 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 0 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 0 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 0 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 0 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 0 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 0 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 0 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 0 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 0 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 0 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 0 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 536870912 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.3.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.3.dump new file mode 100644 index 0000000000..a73a901d33 --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.3.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 0 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 0 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 0 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 0 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 0 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 0 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 0 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 0 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 0 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 0 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 0 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 0 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 0 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 536870912 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.0.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.0.dump new file mode 100644 index 0000000000..994a533ace --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.0.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 67108864 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 67108864 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 67108864 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 67108864 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 67108864 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 67108864 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 67108864 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 67108864 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 67108864 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 67108864 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 67108864 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 67108864 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 67108864 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 603979776 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.1.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.1.dump new file mode 100644 index 0000000000..994a533ace --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.1.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 67108864 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 67108864 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 67108864 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 67108864 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 67108864 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 67108864 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 67108864 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 67108864 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 67108864 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 67108864 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 67108864 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 67108864 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 67108864 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 603979776 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.2.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.2.dump new file mode 100644 index 0000000000..994a533ace --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.2.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 67108864 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 67108864 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 67108864 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 67108864 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 67108864 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 67108864 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 67108864 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 67108864 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 67108864 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 67108864 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 67108864 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 67108864 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 67108864 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 603979776 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.3.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.3.dump new file mode 100644 index 0000000000..994a533ace --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.3.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 67108864 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 67108864 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 67108864 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 67108864 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 67108864 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 67108864 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 67108864 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 67108864 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 67108864 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 67108864 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 67108864 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 67108864 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 67108864 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 603979776 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.unknown_length.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.unknown_length.dump new file mode 100644 index 0000000000..994a533ace --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.reading_within_gop_sample_dependencies.unknown_length.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 67108864 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 67108864 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 67108864 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 67108864 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 67108864 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 67108864 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 67108864 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 67108864 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 67108864 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 67108864 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 67108864 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 67108864 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 67108864 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 603979776 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.unknown_length.dump b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.unknown_length.dump new file mode 100644 index 0000000000..a73a901d33 --- /dev/null +++ b/libraries/test_data/src/test/assets/extractordumps/mp4/sample_with_invalid_nalu.mp4.unknown_length.dump @@ -0,0 +1,150 @@ +seekMap: + isSeekable = true + duration = 1001000 + getPosition(0) = [[timeUs=0, position=1266]] + getPosition(1) = [[timeUs=0, position=1266]] + getPosition(500500) = [[timeUs=0, position=1266]] + getPosition(1001000) = [[timeUs=0, position=1266]] +numberOfTracks = 1 +track 0: + total output bytes = 89876 + sample count = 30 + track duration = 1001000 + format 0: + id = 1 + containerMimeType = video/mp4 + sampleMimeType = video/avc + codecs = avc1.64001F + maxInputSize = 36722 + maxNumReorderSamples = 2 + width = 1080 + height = 720 + frameRate = 29.97 + colorInfo: + lumaBitdepth = 8 + chromaBitdepth = 8 + metadata = entries=[TSSE: description=null: values=[Lavf60.16.100], Mp4Timestamp: creation time=0, modification time=0, timescale=1000] + initializationData: + data = length 29, hash 4746B5D9 + data = length 10, hash 7A0D0F2B + sample 0: + time = 0 + flags = 1 + data = length 36692, hash D216076E + sample 1: + time = 66733 + flags = 0 + data = length 5312, hash D45D3CA0 + sample 2: + time = 33366 + flags = 0 + data = length 599, hash 1BE7812D + sample 3: + time = 200200 + flags = 0 + data = length 7735, hash 4490F110 + sample 4: + time = 133466 + flags = 0 + data = length 987, hash 560B5036 + sample 5: + time = 100100 + flags = 0 + data = length 673, hash ED7CD8C7 + sample 6: + time = 166833 + flags = 0 + data = length 523, hash 3020DF50 + sample 7: + time = 333666 + flags = 0 + data = length 6061, hash 736C72B2 + sample 8: + time = 266933 + flags = 0 + data = length 992, hash FE132F23 + sample 9: + time = 233566 + flags = 0 + data = length 623, hash 5B2C1816 + sample 10: + time = 300300 + flags = 0 + data = length 421, hash 742E69C1 + sample 11: + time = 433766 + flags = 0 + data = length 4899, hash F72F86A1 + sample 12: + time = 400400 + flags = 0 + data = length 568, hash 519A8E50 + sample 13: + time = 367033 + flags = 0 + data = length 620, hash 3990AA39 + sample 14: + time = 567233 + flags = 0 + data = length 5450, hash F06EC4AA + sample 15: + time = 500500 + flags = 0 + data = length 1051, hash 92DFA63A + sample 16: + time = 467133 + flags = 0 + data = length 874, hash 69587FB4 + sample 17: + time = 533866 + flags = 0 + data = length 781, hash 36BE495B + sample 18: + time = 700700 + flags = 0 + data = length 4725, hash AC0C8CD3 + sample 19: + time = 633966 + flags = 0 + data = length 1022, hash 5D8BFF34 + sample 20: + time = 600600 + flags = 0 + data = length 790, hash 99413A99 + sample 21: + time = 667333 + flags = 0 + data = length 610, hash 5E129290 + sample 22: + time = 834166 + flags = 0 + data = length 2751, hash 769974CB + sample 23: + time = 767433 + flags = 0 + data = length 745, hash B78A477A + sample 24: + time = 734066 + flags = 0 + data = length 621, hash CF741E7A + sample 25: + time = 800800 + flags = 0 + data = length 505, hash 1DB4894E + sample 26: + time = 967633 + flags = 0 + data = length 1268, hash C15348DC + sample 27: + time = 900900 + flags = 0 + data = length 880, hash C2DE85D0 + sample 28: + time = 867533 + flags = 0 + data = length 530, hash C9641EB0 + sample 29: + time = 934266 + flags = 536870912 + data = length 568, hash 4FE5C8EA +tracksEnded = true diff --git a/libraries/test_data/src/test/assets/media/mp4/sample_with_invalid_nalu.mp4 b/libraries/test_data/src/test/assets/media/mp4/sample_with_invalid_nalu.mp4 new file mode 100644 index 0000000000..897b6d5060 Binary files /dev/null and b/libraries/test_data/src/test/assets/media/mp4/sample_with_invalid_nalu.mp4 differ