Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: webrtc/common_video/h264/pps_parser.cc

Issue 2265023002: Revert of Add pps id and sps id parsing to the h.264 depacketizer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/common_video/h264/pps_parser.h ('k') | webrtc/common_video/h264/pps_parser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "webrtc/common_video/h264/pps_parser.h" 11 #include "webrtc/common_video/h264/pps_parser.h"
12 12
13 #include <memory>
14
15 #include "webrtc/common_video/h264/h264_common.h" 13 #include "webrtc/common_video/h264/h264_common.h"
16 #include "webrtc/base/bitbuffer.h" 14 #include "webrtc/base/bitbuffer.h"
17 #include "webrtc/base/buffer.h" 15 #include "webrtc/base/buffer.h"
18 #include "webrtc/base/logging.h" 16 #include "webrtc/base/logging.h"
19 17
20 #define RETURN_EMPTY_ON_FAIL(x) \ 18 #define RETURN_EMPTY_ON_FAIL(x) \
21 if (!(x)) { \ 19 if (!(x)) { \
22 return rtc::Optional<PpsParser::PpsState>(); \ 20 return rtc::Optional<PpsParser::PpsState>(); \
23 } 21 }
24 22
25 namespace webrtc { 23 namespace webrtc {
26 24
27 // General note: this is based off the 02/2014 version of the H.264 standard. 25 // General note: this is based off the 02/2014 version of the H.264 standard.
28 // You can find it on this page: 26 // You can find it on this page:
29 // http://www.itu.int/rec/T-REC-H.264 27 // http://www.itu.int/rec/T-REC-H.264
30 28
31 rtc::Optional<PpsParser::PpsState> PpsParser::ParsePps(const uint8_t* data, 29 rtc::Optional<PpsParser::PpsState> PpsParser::ParsePps(const uint8_t* data,
32 size_t length) { 30 size_t length) {
33 // First, parse out rbsp, which is basically the source buffer minus emulation 31 // 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 32 // bytes (the last byte of a 0x00 0x00 0x03 sequence). RBSP is defined in
35 // section 7.3.1 of the H.264 standard. 33 // section 7.3.1 of the H.264 standard.
36 std::unique_ptr<rtc::Buffer> unpacked_buffer = H264::ParseRbsp(data, length); 34 std::unique_ptr<rtc::Buffer> unpacked_buffer = H264::ParseRbsp(data, length);
37 rtc::BitBuffer bit_buffer(unpacked_buffer->data(), unpacked_buffer->size()); 35 rtc::BitBuffer bit_buffer(unpacked_buffer->data(), unpacked_buffer->size());
38 return ParseInternal(&bit_buffer); 36 return ParseInternal(&bit_buffer);
39 } 37 }
40 38
41 rtc::Optional<uint32_t> PpsParser::ParsePpsIdFromSlice(const uint8_t* data,
42 size_t length) {
43 std::unique_ptr<rtc::Buffer> slice_rbsp(H264::ParseRbsp(data, length));
44 rtc::BitBuffer slice_reader(slice_rbsp->data(), slice_rbsp->size());
45
46 uint32_t golomb_tmp;
47 // first_mb_in_slice: ue(v)
48 if (!slice_reader.ReadExponentialGolomb(&golomb_tmp))
49 return rtc::Optional<uint32_t>();
50 // slice_type: ue(v)
51 if (!slice_reader.ReadExponentialGolomb(&golomb_tmp))
52 return rtc::Optional<uint32_t>();
53 // pic_parameter_set_id: ue(v)
54 uint32_t slice_pps_id;
55 if (!slice_reader.ReadExponentialGolomb(&slice_pps_id))
56 return rtc::Optional<uint32_t>();
57 return rtc::Optional<uint32_t>(slice_pps_id);
58 }
59
60 rtc::Optional<PpsParser::PpsState> PpsParser::ParseInternal( 39 rtc::Optional<PpsParser::PpsState> PpsParser::ParseInternal(
61 rtc::BitBuffer* bit_buffer) { 40 rtc::BitBuffer* bit_buffer) {
62 PpsState pps; 41 PpsState pps;
63 42
64 uint32_t bits_tmp; 43 uint32_t bits_tmp;
65 uint32_t golomb_ignored; 44 uint32_t golomb_ignored;
66 // pic_parameter_set_id: ue(v) 45 // pic_parameter_set_id: ue(v)
67 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadExponentialGolomb(&pps.id)); 46 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadExponentialGolomb(&golomb_ignored));
68 // seq_parameter_set_id: ue(v) 47 // seq_parameter_set_id: ue(v)
69 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadExponentialGolomb(&pps.sps_id)); 48 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadExponentialGolomb(&golomb_ignored));
70 // entropy_coding_mode_flag: u(1) 49 // entropy_coding_mode_flag: u(1)
71 uint32_t entropy_coding_mode_flag; 50 uint32_t entropy_coding_mode_flag;
72 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadBits(&entropy_coding_mode_flag, 1)); 51 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadBits(&entropy_coding_mode_flag, 1));
73 // TODO(pbos): Implement CABAC support if spotted in the wild. 52 // TODO(pbos): Implement CABAC support if spotted in the wild.
74 RTC_CHECK(entropy_coding_mode_flag == 0) 53 RTC_CHECK(entropy_coding_mode_flag == 0)
75 << "Don't know how to parse CABAC streams."; 54 << "Don't know how to parse CABAC streams.";
76 // bottom_field_pic_order_in_frame_present_flag: u(1) 55 // bottom_field_pic_order_in_frame_present_flag: u(1)
77 uint32_t bottom_field_pic_order_in_frame_present_flag; 56 uint32_t bottom_field_pic_order_in_frame_present_flag;
78 RETURN_EMPTY_ON_FAIL( 57 RETURN_EMPTY_ON_FAIL(
79 bit_buffer->ReadBits(&bottom_field_pic_order_in_frame_present_flag, 1)); 58 bit_buffer->ReadBits(&bottom_field_pic_order_in_frame_present_flag, 1));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // constrained_intra_pred_flag: u(1) 139 // constrained_intra_pred_flag: u(1)
161 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadBits(&bits_tmp, 2)); 140 RETURN_EMPTY_ON_FAIL(bit_buffer->ReadBits(&bits_tmp, 2));
162 // redundant_pic_cnt_present_flag: u(1) 141 // redundant_pic_cnt_present_flag: u(1)
163 RETURN_EMPTY_ON_FAIL( 142 RETURN_EMPTY_ON_FAIL(
164 bit_buffer->ReadBits(&pps.redundant_pic_cnt_present_flag, 1)); 143 bit_buffer->ReadBits(&pps.redundant_pic_cnt_present_flag, 1));
165 144
166 return rtc::Optional<PpsParser::PpsState>(pps); 145 return rtc::Optional<PpsParser::PpsState>(pps);
167 } 146 }
168 147
169 } // namespace webrtc 148 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_video/h264/pps_parser.h ('k') | webrtc/common_video/h264/pps_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698