| Index: webrtc/common_video/h264/pps_parser.cc
|
| diff --git a/webrtc/common_video/h264/pps_parser.cc b/webrtc/common_video/h264/pps_parser.cc
|
| index 01a6c76d911ed4670016cf439ae1d8dd01cae52f..a48d27bfc7fd8c2706b78dc7b72b41a12d429ac4 100644
|
| --- a/webrtc/common_video/h264/pps_parser.cc
|
| +++ b/webrtc/common_video/h264/pps_parser.cc
|
| @@ -38,6 +38,20 @@ rtc::Optional<PpsParser::PpsState> PpsParser::ParsePps(const uint8_t* data,
|
| return ParseInternal(&bit_buffer);
|
| }
|
|
|
| +bool PpsParser::ParsePpsIds(const uint8_t* data,
|
| + size_t length,
|
| + uint32_t* pps_id,
|
| + uint32_t* sps_id) {
|
| + RTC_DCHECK(pps_id);
|
| + RTC_DCHECK(sps_id);
|
| + // First, parse out rbsp, which is basically the source buffer minus emulation
|
| + // bytes (the last byte of a 0x00 0x00 0x03 sequence). RBSP is defined in
|
| + // section 7.3.1 of the H.264 standard.
|
| + std::unique_ptr<rtc::Buffer> unpacked_buffer = H264::ParseRbsp(data, length);
|
| + rtc::BitBuffer bit_buffer(unpacked_buffer->data(), unpacked_buffer->size());
|
| + return ParsePpsIdsInternal(&bit_buffer, pps_id, sps_id);
|
| +}
|
| +
|
| rtc::Optional<uint32_t> PpsParser::ParsePpsIdFromSlice(const uint8_t* data,
|
| size_t length) {
|
| std::unique_ptr<rtc::Buffer> slice_rbsp(H264::ParseRbsp(data, length));
|
| @@ -61,12 +75,10 @@ rtc::Optional<PpsParser::PpsState> PpsParser::ParseInternal(
|
| rtc::BitBuffer* bit_buffer) {
|
| PpsState pps;
|
|
|
| + RETURN_EMPTY_ON_FAIL(ParsePpsIdsInternal(bit_buffer, &pps.id, &pps.sps_id));
|
| +
|
| uint32_t bits_tmp;
|
| uint32_t golomb_ignored;
|
| - // pic_parameter_set_id: ue(v)
|
| - RETURN_EMPTY_ON_FAIL(bit_buffer->ReadExponentialGolomb(&pps.id));
|
| - // seq_parameter_set_id: ue(v)
|
| - RETURN_EMPTY_ON_FAIL(bit_buffer->ReadExponentialGolomb(&pps.sps_id));
|
| // entropy_coding_mode_flag: u(1)
|
| uint32_t entropy_coding_mode_flag;
|
| RETURN_EMPTY_ON_FAIL(bit_buffer->ReadBits(&entropy_coding_mode_flag, 1));
|
| @@ -166,4 +178,16 @@ rtc::Optional<PpsParser::PpsState> PpsParser::ParseInternal(
|
| return rtc::Optional<PpsParser::PpsState>(pps);
|
| }
|
|
|
| +bool PpsParser::ParsePpsIdsInternal(rtc::BitBuffer* bit_buffer,
|
| + uint32_t* pps_id,
|
| + uint32_t* sps_id) {
|
| + // pic_parameter_set_id: ue(v)
|
| + if (!bit_buffer->ReadExponentialGolomb(pps_id))
|
| + return false;
|
| + // seq_parameter_set_id: ue(v)
|
| + if (!bit_buffer->ReadExponentialGolomb(sps_id))
|
| + return false;
|
| + return true;
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|