mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Fix saiz and senc sample count checks for FMP4
Issue: #7592 PiperOrigin-RevId: 320556981
This commit is contained in:
parent
fd3e10ed76
commit
c29fc94540
@ -809,8 +809,12 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
int defaultSampleInfoSize = saiz.readUnsignedByte();
|
int defaultSampleInfoSize = saiz.readUnsignedByte();
|
||||||
|
|
||||||
int sampleCount = saiz.readUnsignedIntToInt();
|
int sampleCount = saiz.readUnsignedIntToInt();
|
||||||
if (sampleCount != out.sampleCount) {
|
if (sampleCount > out.sampleCount) {
|
||||||
throw new ParserException("Length mismatch: " + sampleCount + ", " + out.sampleCount);
|
throw new ParserException(
|
||||||
|
"Saiz sample count "
|
||||||
|
+ sampleCount
|
||||||
|
+ " is greater than fragment sample count"
|
||||||
|
+ out.sampleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalSize = 0;
|
int totalSize = 0;
|
||||||
@ -826,8 +830,11 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
totalSize += defaultSampleInfoSize * sampleCount;
|
totalSize += defaultSampleInfoSize * sampleCount;
|
||||||
Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption);
|
Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption);
|
||||||
}
|
}
|
||||||
|
Arrays.fill(out.sampleHasSubsampleEncryptionTable, sampleCount, out.sampleCount, false);
|
||||||
|
if (totalSize > 0) {
|
||||||
out.initEncryptionData(totalSize);
|
out.initEncryptionData(totalSize);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a saio atom (defined in 14496-12).
|
* Parses a saio atom (defined in 14496-12).
|
||||||
@ -1068,8 +1075,16 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
|
|
||||||
boolean subsampleEncryption = (flags & 0x02 /* use_subsample_encryption */) != 0;
|
boolean subsampleEncryption = (flags & 0x02 /* use_subsample_encryption */) != 0;
|
||||||
int sampleCount = senc.readUnsignedIntToInt();
|
int sampleCount = senc.readUnsignedIntToInt();
|
||||||
if (sampleCount != out.sampleCount) {
|
if (sampleCount == 0) {
|
||||||
throw new ParserException("Length mismatch: " + sampleCount + ", " + out.sampleCount);
|
// Samples are unencrypted.
|
||||||
|
Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, out.sampleCount, false);
|
||||||
|
return;
|
||||||
|
} else if (sampleCount != out.sampleCount) {
|
||||||
|
throw new ParserException(
|
||||||
|
"Senc sample count "
|
||||||
|
+ sampleCount
|
||||||
|
+ " is different from fragment sample count"
|
||||||
|
+ out.sampleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption);
|
Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user