Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1479,18 +1479,17 @@ private static void parseSampleGroups(
sgpd.setPosition(Mp4Box.HEADER_SIZE);
int sgpdVersion = BoxParser.parseFullBoxVersion(sgpd.readInt());
sgpd.skipBytes(4); // grouping_type == seig.
if (sgpdVersion == 1) {
if (sgpd.readUnsignedInt() == 0) {
throw ParserException.createForUnsupportedContainerFeature(
"Variable length description in sgpd found (unsupported)");
}
} else if (sgpdVersion >= 2) {
long default_length = sgpdVersion >= 1 ? sgpd.readUnsignedInt() : 0;
if (sgpdVersion >= 2) {
sgpd.skipBytes(4); // default_sample_description_index.
}
if (sgpd.readUnsignedInt() != 1) { // entry_count.
throw ParserException.createForUnsupportedContainerFeature(
"Entry count in sgpd != 1 (unsupported).");
}
if (sgpdVersion >= 1 && default_length == 0) {
sgpd.skipBytes(4); // description_length.
}

// CencSampleEncryptionInformationGroupEntry
sgpd.skipBytes(1); // reserved = 0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ public void sniff_returnsFalseWithoutPeekingLargeStbl() throws Exception {
assertThat(input.getMaxPeekLimit()).isLessThan(500);
}

@Test
public void extract_h264WithVariableLengthSgpdBox() throws Exception {
FragmentedMp4Extractor extractor =
new FragmentedMp4Extractor(SubtitleParser.Factory.UNSUPPORTED);
FakeExtractorOutput output =
TestUtil.extractAllSamplesFromFile(
extractor,
ApplicationProvider.getApplicationContext(),
"media/mp4/sample_fragmented_variable_length_sgpd.mp4");

DumpFileAsserts.assertOutput(
ApplicationProvider.getApplicationContext(),
output,
"extractordumps/mp4/fragmented_variable_length_sgpd.mp4");
}

private static FakeExtractorInput createInputForSample(String sample) throws IOException {
return new FakeExtractorInput.Builder()
.setData(
Expand Down
Loading