Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 if (!(x)) { \ | 21 if (!(x)) { \ |
| 22 return rtc::Optional<PpsParser::PpsState>(); \ | 22 return rtc::Optional<PpsParser::PpsState>(); \ |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace webrtc { | 25 namespace webrtc { |
| 26 | 26 |
| 27 // General note: this is based off the 02/2014 version of the H.264 standard. | 27 // General note: this is based off the 02/2014 version of the H.264 standard. |
| 28 // You can find it on this page: | 28 // You can find it on this page: |
| 29 // http://www.itu.int/rec/T-REC-H.264 | 29 // http://www.itu.int/rec/T-REC-H.264 |
| 30 | 30 |
| 31 bool PpsParser::ParsePpsIds(const uint8_t* data, | |
|
danilchap
2016/09/07 10:38:51
Function declaration order should match function d
| |
| 32 size_t length, | |
| 33 uint32_t* pps_id, | |
| 34 uint32_t* sps_id) { | |
| 35 RTC_DCHECK(pps_id); | |
| 36 RTC_DCHECK(sps_id); | |
| 37 // First, parse out rbsp, which is basically the source buffer minus emulation | |
| 38 // bytes (the last byte of a 0x00 0x00 0x03 sequence). RBSP is defined in | |
| 39 // section 7.3.1 of the H.264 standard. | |
| 40 std::unique_ptr<rtc::Buffer> unpacked_buffer = H264::ParseRbsp(data, length); | |
| 41 rtc::BitBuffer bit_buffer(unpacked_buffer->data(), unpacked_buffer->size()); | |
| 42 return ParsePpsIdsInternal(&bit_buffer, pps_id, sps_id); | |
| 43 } | |
| 44 | |
| 45 bool PpsParser::ParsePpsIdsInternal(rtc::BitBuffer* bit_buffer, | |
|
danilchap
2016/09/07 10:38:51
and this one after ParseInternal
| |
| 46 uint32_t* pps_id, | |
| 47 uint32_t* sps_id) { | |
| 48 // pic_parameter_set_id: ue(v) | |
| 49 if (!bit_buffer->ReadExponentialGolomb(pps_id)) | |
| 50 return false; | |
| 51 // seq_parameter_set_id: ue(v) | |
| 52 if (!bit_buffer->ReadExponentialGolomb(sps_id)) | |
| 53 return false; | |
| 54 return true; | |
| 55 } | |
| 56 | |
| 31 rtc::Optional<PpsParser::PpsState> PpsParser::ParsePps(const uint8_t* data, | 57 rtc::Optional<PpsParser::PpsState> PpsParser::ParsePps(const uint8_t* data, |
| 32 size_t length) { | 58 size_t length) { |
| 33 // First, parse out rbsp, which is basically the source buffer minus emulation | 59 // First, parse out rbsp, which is basically the source buffer minus emulation |
| 34 // bytes (the last byte of a 0x00 0x00 0x03 sequence). RBSP is defined in | 60 // bytes (the last byte of a 0x00 0x00 0x03 sequence). RBSP is defined in |
| 35 // section 7.3.1 of the H.264 standard. | 61 // section 7.3.1 of the H.264 standard. |
| 36 std::unique_ptr<rtc::Buffer> unpacked_buffer = H264::ParseRbsp(data, length); | 62 std::unique_ptr<rtc::Buffer> unpacked_buffer = H264::ParseRbsp(data, length); |
| 37 rtc::BitBuffer bit_buffer(unpacked_buffer->data(), unpacked_buffer->size()); | 63 rtc::BitBuffer bit_buffer(unpacked_buffer->data(), unpacked_buffer->size()); |
| 38 return ParseInternal(&bit_buffer); | 64 return ParseInternal(&bit_buffer); |
| 39 } | 65 } |
| 40 | 66 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 54 uint32_t slice_pps_id; | 80 uint32_t slice_pps_id; |
| 55 if (!slice_reader.ReadExponentialGolomb(&slice_pps_id)) | 81 if (!slice_reader.ReadExponentialGolomb(&slice_pps_id)) |
| 56 return rtc::Optional<uint32_t>(); | 82 return rtc::Optional<uint32_t>(); |
| 57 return rtc::Optional<uint32_t>(slice_pps_id); | 83 return rtc::Optional<uint32_t>(slice_pps_id); |
| 58 } | 84 } |
| 59 | 85 |
| 60 rtc::Optional<PpsParser::PpsState> PpsParser::ParseInternal( | 86 rtc::Optional<PpsParser::PpsState> PpsParser::ParseInternal( |
| 61 rtc::BitBuffer* bit_buffer) { | 87 rtc::BitBuffer* bit_buffer) { |
| 62 PpsState pps; | 88 PpsState pps; |
| 63 | 89 |
| 90 RETURN_EMPTY_ON_FAIL(ParsePpsIdsInternal(bit_buffer, &pps.id, &pps.sps_id)); | |
| 91 | |
| 64 uint32_t bits_tmp; | 92 uint32_t bits_tmp; |
| 65 uint32_t golomb_ignored; | 93 uint32_t golomb_ignored; |
| 66 // pic_parameter_set_id: ue(v) | |
| 67 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadExponentialGolomb(&pps.id)); | |
| 68 // seq_parameter_set_id: ue(v) | |
| 69 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadExponentialGolomb(&pps.sps_id)); | |
| 70 // entropy_coding_mode_flag: u(1) | 94 // entropy_coding_mode_flag: u(1) |
| 71 uint32_t entropy_coding_mode_flag; | 95 uint32_t entropy_coding_mode_flag; |
| 72 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadBits(&entropy_coding_mode_flag, 1)); | 96 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadBits(&entropy_coding_mode_flag, 1)); |
| 73 // TODO(pbos): Implement CABAC support if spotted in the wild. | 97 // TODO(pbos): Implement CABAC support if spotted in the wild. |
| 74 RTC_CHECK(entropy_coding_mode_flag == 0) | 98 RTC_CHECK(entropy_coding_mode_flag == 0) |
| 75 << "Don't know how to parse CABAC streams."; | 99 << "Don't know how to parse CABAC streams."; |
| 76 // bottom_field_pic_order_in_frame_present_flag: u(1) | 100 // bottom_field_pic_order_in_frame_present_flag: u(1) |
| 77 uint32_t bottom_field_pic_order_in_frame_present_flag; | 101 uint32_t bottom_field_pic_order_in_frame_present_flag; |
| 78 RETURN_EMPTY_ON_FAIL( | 102 RETURN_EMPTY_ON_FAIL( |
| 79 bit_buffer->ReadBits(&bottom_field_pic_order_in_frame_present_flag, 1)); | 103 bit_buffer->ReadBits(&bottom_field_pic_order_in_frame_present_flag, 1)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 // constrained_intra_pred_flag: u(1) | 184 // constrained_intra_pred_flag: u(1) |
| 161 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadBits(&bits_tmp, 2)); | 185 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadBits(&bits_tmp, 2)); |
| 162 // redundant_pic_cnt_present_flag: u(1) | 186 // redundant_pic_cnt_present_flag: u(1) |
| 163 RETURN_EMPTY_ON_FAIL( | 187 RETURN_EMPTY_ON_FAIL( |
| 164 bit_buffer->ReadBits(&pps.redundant_pic_cnt_present_flag, 1)); | 188 bit_buffer->ReadBits(&pps.redundant_pic_cnt_present_flag, 1)); |
| 165 | 189 |
| 166 return rtc::Optional<PpsParser::PpsState>(pps); | 190 return rtc::Optional<PpsParser::PpsState>(pps); |
| 167 } | 191 } |
| 168 | 192 |
| 169 } // namespace webrtc | 193 } // namespace webrtc |
| OLD | NEW |