mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1579136 - do not read content from null NAL. r=jya
Dealing with a case where `DecodeNALUnit()` returns nullptr which we should not try to create bit reader and decode anything. In addition, wrap these logic to `DecodedISlice()` in order to keep consistent with a case where we decode SEI. Differential Revision: https://phabricator.services.mozilla.com/D44875 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c843481e4b
commit
677f012080
@ -985,16 +985,8 @@ uint32_t H264::ComputeMaxRefFrames(const mozilla::MediaByteBuffer* aExtraData) {
|
||||
return FrameType::I_FRAME;
|
||||
}
|
||||
} else if (nalType == H264_NAL_SLICE) {
|
||||
// According to ITU-T Rec H.264 Table 7.3.3, read the slice type from
|
||||
// slice_header, and the slice type 2 and 7 are representing I slice.
|
||||
RefPtr<mozilla::MediaByteBuffer> decodedNAL = DecodeNALUnit(p, nalLen);
|
||||
BitReader br(decodedNAL);
|
||||
// Skip `first_mb_in_slice`
|
||||
br.ReadUE();
|
||||
// The value of slice type can go from 0 to 9, but the value between 5 to
|
||||
// 9 are actually equal to 0 to 4.
|
||||
const uint32_t sliceType = br.ReadUE() % 5;
|
||||
if (sliceType == SLICE_TYPES::I_SLICE || sliceType == SI_SLICE) {
|
||||
if (DecodeISlice(decodedNAL)) {
|
||||
return FrameType::I_FRAME;
|
||||
}
|
||||
}
|
||||
@ -1187,6 +1179,23 @@ static inline Result<Ok, nsresult> ReadSEIInt(BufferReader& aBr,
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool H264::DecodeISlice(const mozilla::MediaByteBuffer* aSlice) {
|
||||
if (!aSlice) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// According to ITU-T Rec H.264 Table 7.3.3, read the slice type from
|
||||
// slice_header, and the slice type 2 and 7 are representing I slice.
|
||||
BitReader br(aSlice);
|
||||
// Skip `first_mb_in_slice`
|
||||
br.ReadUE();
|
||||
// The value of slice type can go from 0 to 9, but the value between 5 to
|
||||
// 9 are actually equal to 0 to 4.
|
||||
const uint32_t sliceType = br.ReadUE() % 5;
|
||||
return sliceType == SLICE_TYPES::I_SLICE || sliceType == SI_SLICE;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool H264::DecodeRecoverySEI(const mozilla::MediaByteBuffer* aSEI,
|
||||
SEIRecoveryData& aDest) {
|
||||
|
@ -510,6 +510,9 @@ class H264 {
|
||||
// point.
|
||||
static bool DecodeRecoverySEI(const mozilla::MediaByteBuffer* aSEI,
|
||||
SEIRecoveryData& aDest);
|
||||
// Decode NAL Slice payload and return true if its slice type is I slice or SI
|
||||
// slice.
|
||||
static bool DecodeISlice(const mozilla::MediaByteBuffer* aSlice);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user