| Index: webrtc/common_video/h264/pps_parser_unittest.cc
|
| diff --git a/webrtc/common_video/h264/pps_parser_unittest.cc b/webrtc/common_video/h264/pps_parser_unittest.cc
|
| index 198343908368c545e66df93548ca8adb5456e1ef..8be8b23ee3882723b52622aa665bc6b276c0f04b 100644
|
| --- a/webrtc/common_video/h264/pps_parser_unittest.cc
|
| +++ b/webrtc/common_video/h264/pps_parser_unittest.cc
|
| @@ -11,6 +11,7 @@
|
| #include "webrtc/common_video/h264/pps_parser.h"
|
|
|
| #include <limits>
|
| +#include <memory>
|
|
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -20,8 +21,17 @@
|
|
|
| namespace webrtc {
|
|
|
| -static const size_t kPpsBufferMaxSize = 256;
|
| -static const uint32_t kIgnored = 0;
|
| +namespace {
|
| +// Contains enough of the image slice to contain slice QP.
|
| +const uint8_t kH264BitstreamChunk[] = {
|
| + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x20, 0xda, 0x01, 0x40, 0x16,
|
| + 0xe8, 0x06, 0xd0, 0xa1, 0x35, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x06,
|
| + 0xe2, 0x00, 0x00, 0x00, 0x01, 0x65, 0xb8, 0x40, 0xf0, 0x8c, 0x03, 0xf2,
|
| + 0x75, 0x67, 0xad, 0x41, 0x64, 0x24, 0x0e, 0xa0, 0xb2, 0x12, 0x1e, 0xf8,
|
| +};
|
| +const size_t kPpsBufferMaxSize = 256;
|
| +const uint32_t kIgnored = 0;
|
| +} // namespace
|
|
|
| void WritePps(const PpsParser::PpsState& pps,
|
| int slice_group_map_type,
|
| @@ -32,9 +42,9 @@ void WritePps(const PpsParser::PpsState& pps,
|
| rtc::BitBufferWriter bit_buffer(data, kPpsBufferMaxSize);
|
|
|
| // pic_parameter_set_id: ue(v)
|
| - bit_buffer.WriteExponentialGolomb(kIgnored);
|
| + bit_buffer.WriteExponentialGolomb(pps.id);
|
| // seq_parameter_set_id: ue(v)
|
| - bit_buffer.WriteExponentialGolomb(kIgnored);
|
| + bit_buffer.WriteExponentialGolomb(pps.sps_id);
|
| // entropy_coding_mode_flag: u(1)
|
| bit_buffer.WriteBits(kIgnored, 1);
|
| // bottom_field_pic_order_in_frame_present_flag: u(1)
|
| @@ -175,6 +185,8 @@ class PpsParserTest : public ::testing::Test {
|
| EXPECT_EQ(pps.redundant_pic_cnt_present_flag,
|
| parsed_pps_->redundant_pic_cnt_present_flag);
|
| EXPECT_EQ(pps.pic_init_qp_minus26, parsed_pps_->pic_init_qp_minus26);
|
| + EXPECT_EQ(pps.id, parsed_pps_->id);
|
| + EXPECT_EQ(pps.sps_id, parsed_pps_->sps_id);
|
| }
|
|
|
| PpsParser::PpsState generated_pps_;
|
| @@ -192,10 +204,19 @@ TEST_F(PpsParserTest, MaxPps) {
|
| generated_pps_.redundant_pic_cnt_present_flag = 1; // 1 bit value.
|
| generated_pps_.weighted_bipred_idc = (1 << 2) - 1; // 2 bit value.
|
| generated_pps_.weighted_pred_flag = true;
|
| + generated_pps_.id = 2;
|
| + generated_pps_.sps_id = 1;
|
| RunTest();
|
|
|
| generated_pps_.pic_init_qp_minus26 = std::numeric_limits<int32_t>::min() + 1;
|
| RunTest();
|
| }
|
|
|
| +TEST_F(PpsParserTest, PpsIdFromSlice) {
|
| + rtc::Optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice(
|
| + kH264BitstreamChunk, sizeof(kH264BitstreamChunk));
|
| + ASSERT_TRUE(pps_id);
|
| + EXPECT_EQ(2u, *pps_id);
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|