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

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

Issue 2238253002: 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: Retry without including h264_common.h Created 4 years, 4 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/sps_parser.cc ('k') | webrtc/common_video/h264/sps_vui_rewriter.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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 23 matching lines...) Expand all
34 // two start codes (0 0 0 1 or 0 0 1). The first byte should be 0x67, 34 // two start codes (0 0 0 1 or 0 0 1). The first byte should be 0x67,
35 // which should be stripped out before being passed to the parser. 35 // which should be stripped out before being passed to the parser.
36 36
37 static const size_t kSpsBufferMaxSize = 256; 37 static const size_t kSpsBufferMaxSize = 256;
38 38
39 // Generates a fake SPS with basically everything empty but the width/height. 39 // Generates a fake SPS with basically everything empty but the width/height.
40 // Pass in a buffer of at least kSpsBufferMaxSize. 40 // Pass in a buffer of at least kSpsBufferMaxSize.
41 // The fake SPS that this generates also always has at least one emulation byte 41 // The fake SPS that this generates also always has at least one emulation byte
42 // at offset 2, since the first two bytes are always 0, and has a 0x3 as the 42 // at offset 2, since the first two bytes are always 0, and has a 0x3 as the
43 // level_idc, to make sure the parser doesn't eat all 0x3 bytes. 43 // level_idc, to make sure the parser doesn't eat all 0x3 bytes.
44 void GenerateFakeSps(uint16_t width, uint16_t height, rtc::Buffer* out_buffer) { 44 void GenerateFakeSps(uint16_t width,
45 uint16_t height,
46 int id,
47 rtc::Buffer* out_buffer) {
45 uint8_t rbsp[kSpsBufferMaxSize] = {0}; 48 uint8_t rbsp[kSpsBufferMaxSize] = {0};
46 rtc::BitBufferWriter writer(rbsp, kSpsBufferMaxSize); 49 rtc::BitBufferWriter writer(rbsp, kSpsBufferMaxSize);
47 // Profile byte. 50 // Profile byte.
48 writer.WriteUInt8(0); 51 writer.WriteUInt8(0);
49 // Constraint sets and reserved zero bits. 52 // Constraint sets and reserved zero bits.
50 writer.WriteUInt8(0); 53 writer.WriteUInt8(0);
51 // level_idc. 54 // level_idc.
52 writer.WriteUInt8(0x3u); 55 writer.WriteUInt8(0x3u);
53 // seq_paramter_set_id. 56 // seq_paramter_set_id.
54 writer.WriteExponentialGolomb(0); 57 writer.WriteExponentialGolomb(id);
55 // Profile is not special, so we skip all the chroma format settings. 58 // Profile is not special, so we skip all the chroma format settings.
56 59
57 // Now some bit magic. 60 // Now some bit magic.
58 // log2_max_frame_num_minus4: ue(v). 0 is fine. 61 // log2_max_frame_num_minus4: ue(v). 0 is fine.
59 writer.WriteExponentialGolomb(0); 62 writer.WriteExponentialGolomb(0);
60 // pic_order_cnt_type: ue(v). 0 is the type we want. 63 // pic_order_cnt_type: ue(v). 0 is the type we want.
61 writer.WriteExponentialGolomb(0); 64 writer.WriteExponentialGolomb(0);
62 // log2_max_pic_order_cnt_lsb_minus4: ue(v). 0 is fine. 65 // log2_max_pic_order_cnt_lsb_minus4: ue(v). 0 is fine.
63 writer.WriteExponentialGolomb(0); 66 writer.WriteExponentialGolomb(0);
64 // max_num_ref_frames: ue(v). 0 is fine. 67 // max_num_ref_frames: ue(v). 0 is fine.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00, 147 0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00,
145 0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60}; 148 0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60};
146 EXPECT_TRUE( 149 EXPECT_TRUE(
147 static_cast<bool>(sps_ = SpsParser::ParseSps(buffer, arraysize(buffer)))); 150 static_cast<bool>(sps_ = SpsParser::ParseSps(buffer, arraysize(buffer))));
148 EXPECT_EQ(200u, sps_->width); 151 EXPECT_EQ(200u, sps_->width);
149 EXPECT_EQ(400u, sps_->height); 152 EXPECT_EQ(400u, sps_->height);
150 } 153 }
151 154
152 TEST_F(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) { 155 TEST_F(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) {
153 rtc::Buffer buffer; 156 rtc::Buffer buffer;
154 GenerateFakeSps(320u, 180u, &buffer); 157 GenerateFakeSps(320u, 180u, 1, &buffer);
155 EXPECT_TRUE(static_cast<bool>( 158 EXPECT_TRUE(static_cast<bool>(
156 sps_ = SpsParser::ParseSps(buffer.data(), buffer.size()))); 159 sps_ = SpsParser::ParseSps(buffer.data(), buffer.size())));
157 EXPECT_EQ(320u, sps_->width); 160 EXPECT_EQ(320u, sps_->width);
158 EXPECT_EQ(180u, sps_->height); 161 EXPECT_EQ(180u, sps_->height);
162 EXPECT_EQ(1u, sps_->id);
159 } 163 }
160 164
161 TEST_F(H264SpsParserTest, TestSyntheticSPSWeirdResolution) { 165 TEST_F(H264SpsParserTest, TestSyntheticSPSWeirdResolution) {
162 rtc::Buffer buffer; 166 rtc::Buffer buffer;
163 GenerateFakeSps(156u, 122u, &buffer); 167 GenerateFakeSps(156u, 122u, 2, &buffer);
164 EXPECT_TRUE(static_cast<bool>( 168 EXPECT_TRUE(static_cast<bool>(
165 sps_ = SpsParser::ParseSps(buffer.data(), buffer.size()))); 169 sps_ = SpsParser::ParseSps(buffer.data(), buffer.size())));
166 EXPECT_EQ(156u, sps_->width); 170 EXPECT_EQ(156u, sps_->width);
167 EXPECT_EQ(122u, sps_->height); 171 EXPECT_EQ(122u, sps_->height);
172 EXPECT_EQ(2u, sps_->id);
168 } 173 }
169 174
170 } // namespace webrtc 175 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_video/h264/sps_parser.cc ('k') | webrtc/common_video/h264/sps_vui_rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698