From 00ff04ffad4a640c962116ae828017c0a2d6912b Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Thu, 22 Oct 2015 10:24:53 -0700 Subject: [PATCH] Relax requirement on reserved bits when parsing AVCC Issue #44 Change-Id: I84235a4d94225e2bf1777443611ad19429b958d4 --- packager/media/filters/h264_parser.cc | 19 +++---------------- packager/media/formats/mp4/box_definitions.cc | 5 ++--- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/packager/media/filters/h264_parser.cc b/packager/media/filters/h264_parser.cc index ef51ea4129..afc91ad9ef 100644 --- a/packager/media/filters/h264_parser.cc +++ b/packager/media/filters/h264_parser.cc @@ -32,25 +32,12 @@ bool ExtractResolutionFromDecoderConfig(const uint8_t* avc_decoder_config_data, RCHECK(reader.Read1(&value)); RCHECK(value == 1); - // avc profile. No value check. - RCHECK(reader.Read1(&value)); + // Skip avc profile, profile compatibility, avc level, and length size. + RCHECK(reader.SkipBytes(4)); - // profile compatibility. No value check. + // Reserved and num sps. RCHECK(reader.Read1(&value)); - // avc level indication. No value check. - RCHECK(reader.Read1(&value)); - - // reserved and length sized minus one. - RCHECK(reader.Read1(&value)); - // upper 6 bits are reserved and must be 111111. - RCHECK((value & 0xFC) == 0xFC); - - // reserved and num sps. - RCHECK(reader.Read1(&value)); - // upper 3 bits are reserved for 0b111. - RCHECK((value & 0xE0) == 0xE0); - const uint8_t num_sps = value & 0x1F; if (num_sps < 1) { LOG(ERROR) << "No SPS found."; diff --git a/packager/media/formats/mp4/box_definitions.cc b/packager/media/formats/mp4/box_definitions.cc index 2f0e2fb82b..89d41fe6da 100644 --- a/packager/media/formats/mp4/box_definitions.cc +++ b/packager/media/formats/mp4/box_definitions.cc @@ -902,12 +902,11 @@ bool AVCDecoderConfigurationRecord::ParseData(BufferReader* reader) { reader->Read1(&avc_level)); uint8_t length_size_minus_one; - RCHECK(reader->Read1(&length_size_minus_one) && - (length_size_minus_one & 0xfc) == 0xfc); + RCHECK(reader->Read1(&length_size_minus_one)); length_size = (length_size_minus_one & 0x3) + 1; uint8_t num_sps; - RCHECK(reader->Read1(&num_sps) && (num_sps & 0xe0) == 0xe0); + RCHECK(reader->Read1(&num_sps)); num_sps &= 0x1f; sps_list.resize(num_sps);