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 28 matching lines...) Expand all Loading... |
39 int pic_size_in_map_units, | 39 int pic_size_in_map_units, |
40 rtc::Buffer* out_buffer) { | 40 rtc::Buffer* out_buffer) { |
41 uint8_t data[kPpsBufferMaxSize] = {0}; | 41 uint8_t data[kPpsBufferMaxSize] = {0}; |
42 rtc::BitBufferWriter bit_buffer(data, kPpsBufferMaxSize); | 42 rtc::BitBufferWriter bit_buffer(data, kPpsBufferMaxSize); |
43 | 43 |
44 // pic_parameter_set_id: ue(v) | 44 // pic_parameter_set_id: ue(v) |
45 bit_buffer.WriteExponentialGolomb(pps.id); | 45 bit_buffer.WriteExponentialGolomb(pps.id); |
46 // seq_parameter_set_id: ue(v) | 46 // seq_parameter_set_id: ue(v) |
47 bit_buffer.WriteExponentialGolomb(pps.sps_id); | 47 bit_buffer.WriteExponentialGolomb(pps.sps_id); |
48 // entropy_coding_mode_flag: u(1) | 48 // entropy_coding_mode_flag: u(1) |
49 bit_buffer.WriteBits(kIgnored, 1); | 49 bit_buffer.WriteBits(pps.entropy_coding_mode_flag, 1); |
50 // bottom_field_pic_order_in_frame_present_flag: u(1) | 50 // bottom_field_pic_order_in_frame_present_flag: u(1) |
51 bit_buffer.WriteBits(pps.bottom_field_pic_order_in_frame_present_flag ? 1 : 0, | 51 bit_buffer.WriteBits(pps.bottom_field_pic_order_in_frame_present_flag ? 1 : 0, |
52 1); | 52 1); |
53 // num_slice_groups_minus1: ue(v) | 53 // num_slice_groups_minus1: ue(v) |
54 RTC_CHECK_GT(num_slice_groups, 0); | 54 RTC_CHECK_GT(num_slice_groups, 0); |
55 bit_buffer.WriteExponentialGolomb(num_slice_groups - 1); | 55 bit_buffer.WriteExponentialGolomb(num_slice_groups - 1); |
56 | 56 |
57 if (num_slice_groups > 1) { | 57 if (num_slice_groups > 1) { |
58 // slice_group_map_type: ue(v) | 58 // slice_group_map_type: ue(v) |
59 bit_buffer.WriteExponentialGolomb(slice_group_map_type); | 59 bit_buffer.WriteExponentialGolomb(slice_group_map_type); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 int pic_size_in_map_units) { | 175 int pic_size_in_map_units) { |
176 buffer_.Clear(); | 176 buffer_.Clear(); |
177 WritePps(pps, slice_group_map_type, num_slice_groups, pic_size_in_map_units, | 177 WritePps(pps, slice_group_map_type, num_slice_groups, pic_size_in_map_units, |
178 &buffer_); | 178 &buffer_); |
179 parsed_pps_ = PpsParser::ParsePps(buffer_.data(), buffer_.size()); | 179 parsed_pps_ = PpsParser::ParsePps(buffer_.data(), buffer_.size()); |
180 EXPECT_TRUE(static_cast<bool>(parsed_pps_)); | 180 EXPECT_TRUE(static_cast<bool>(parsed_pps_)); |
181 EXPECT_EQ(pps.bottom_field_pic_order_in_frame_present_flag, | 181 EXPECT_EQ(pps.bottom_field_pic_order_in_frame_present_flag, |
182 parsed_pps_->bottom_field_pic_order_in_frame_present_flag); | 182 parsed_pps_->bottom_field_pic_order_in_frame_present_flag); |
183 EXPECT_EQ(pps.weighted_pred_flag, parsed_pps_->weighted_pred_flag); | 183 EXPECT_EQ(pps.weighted_pred_flag, parsed_pps_->weighted_pred_flag); |
184 EXPECT_EQ(pps.weighted_bipred_idc, parsed_pps_->weighted_bipred_idc); | 184 EXPECT_EQ(pps.weighted_bipred_idc, parsed_pps_->weighted_bipred_idc); |
| 185 EXPECT_EQ(pps.entropy_coding_mode_flag, |
| 186 parsed_pps_->entropy_coding_mode_flag); |
185 EXPECT_EQ(pps.redundant_pic_cnt_present_flag, | 187 EXPECT_EQ(pps.redundant_pic_cnt_present_flag, |
186 parsed_pps_->redundant_pic_cnt_present_flag); | 188 parsed_pps_->redundant_pic_cnt_present_flag); |
187 EXPECT_EQ(pps.pic_init_qp_minus26, parsed_pps_->pic_init_qp_minus26); | 189 EXPECT_EQ(pps.pic_init_qp_minus26, parsed_pps_->pic_init_qp_minus26); |
188 EXPECT_EQ(pps.id, parsed_pps_->id); | 190 EXPECT_EQ(pps.id, parsed_pps_->id); |
189 EXPECT_EQ(pps.sps_id, parsed_pps_->sps_id); | 191 EXPECT_EQ(pps.sps_id, parsed_pps_->sps_id); |
190 } | 192 } |
191 | 193 |
192 PpsParser::PpsState generated_pps_; | 194 PpsParser::PpsState generated_pps_; |
193 rtc::Buffer buffer_; | 195 rtc::Buffer buffer_; |
194 rtc::Optional<PpsParser::PpsState> parsed_pps_; | 196 rtc::Optional<PpsParser::PpsState> parsed_pps_; |
195 }; | 197 }; |
196 | 198 |
197 TEST_F(PpsParserTest, ZeroPps) { | 199 TEST_F(PpsParserTest, ZeroPps) { |
198 RunTest(); | 200 RunTest(); |
199 } | 201 } |
200 | 202 |
201 TEST_F(PpsParserTest, MaxPps) { | 203 TEST_F(PpsParserTest, MaxPps) { |
202 generated_pps_.bottom_field_pic_order_in_frame_present_flag = true; | 204 generated_pps_.bottom_field_pic_order_in_frame_present_flag = true; |
203 generated_pps_.pic_init_qp_minus26 = std::numeric_limits<int32_t>::max(); | 205 generated_pps_.pic_init_qp_minus26 = std::numeric_limits<int32_t>::max(); |
204 generated_pps_.redundant_pic_cnt_present_flag = 1; // 1 bit value. | 206 generated_pps_.redundant_pic_cnt_present_flag = 1; // 1 bit value. |
205 generated_pps_.weighted_bipred_idc = (1 << 2) - 1; // 2 bit value. | 207 generated_pps_.weighted_bipred_idc = (1 << 2) - 1; // 2 bit value. |
206 generated_pps_.weighted_pred_flag = true; | 208 generated_pps_.weighted_pred_flag = true; |
| 209 generated_pps_.entropy_coding_mode_flag = true; |
207 generated_pps_.id = 2; | 210 generated_pps_.id = 2; |
208 generated_pps_.sps_id = 1; | 211 generated_pps_.sps_id = 1; |
209 RunTest(); | 212 RunTest(); |
210 | 213 |
211 generated_pps_.pic_init_qp_minus26 = std::numeric_limits<int32_t>::min() + 1; | 214 generated_pps_.pic_init_qp_minus26 = std::numeric_limits<int32_t>::min() + 1; |
212 RunTest(); | 215 RunTest(); |
213 } | 216 } |
214 | 217 |
215 TEST_F(PpsParserTest, PpsIdFromSlice) { | 218 TEST_F(PpsParserTest, PpsIdFromSlice) { |
216 rtc::Optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice( | 219 rtc::Optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice( |
217 kH264BitstreamChunk, sizeof(kH264BitstreamChunk)); | 220 kH264BitstreamChunk, sizeof(kH264BitstreamChunk)); |
218 ASSERT_TRUE(pps_id); | 221 ASSERT_TRUE(pps_id); |
219 EXPECT_EQ(2u, *pps_id); | 222 EXPECT_EQ(2u, *pps_id); |
220 } | 223 } |
221 | 224 |
222 } // namespace webrtc | 225 } // namespace webrtc |
OLD | NEW |