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

Side by Side Diff: webrtc/common_video/h264/sps_parser_unittest.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/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, 44 void GenerateFakeSps(uint16_t width, uint16_t height, rtc::Buffer* out_buffer) {
45 uint16_t height,
46 int id,
47 rtc::Buffer* out_buffer) {
48 uint8_t rbsp[kSpsBufferMaxSize] = {0}; 45 uint8_t rbsp[kSpsBufferMaxSize] = {0};
49 rtc::BitBufferWriter writer(rbsp, kSpsBufferMaxSize); 46 rtc::BitBufferWriter writer(rbsp, kSpsBufferMaxSize);
50 // Profile byte. 47 // Profile byte.
51 writer.WriteUInt8(0); 48 writer.WriteUInt8(0);
52 // Constraint sets and reserved zero bits. 49 // Constraint sets and reserved zero bits.
53 writer.WriteUInt8(0); 50 writer.WriteUInt8(0);
54 // level_idc. 51 // level_idc.
55 writer.WriteUInt8(0x3u); 52 writer.WriteUInt8(0x3u);
56 // seq_paramter_set_id. 53 // seq_paramter_set_id.
57 writer.WriteExponentialGolomb(id); 54 writer.WriteExponentialGolomb(0);
58 // Profile is not special, so we skip all the chroma format settings. 55 // Profile is not special, so we skip all the chroma format settings.
59 56
60 // Now some bit magic. 57 // Now some bit magic.
61 // log2_max_frame_num_minus4: ue(v). 0 is fine. 58 // log2_max_frame_num_minus4: ue(v). 0 is fine.
62 writer.WriteExponentialGolomb(0); 59 writer.WriteExponentialGolomb(0);
63 // pic_order_cnt_type: ue(v). 0 is the type we want. 60 // pic_order_cnt_type: ue(v). 0 is the type we want.
64 writer.WriteExponentialGolomb(0); 61 writer.WriteExponentialGolomb(0);
65 // log2_max_pic_order_cnt_lsb_minus4: ue(v). 0 is fine. 62 // log2_max_pic_order_cnt_lsb_minus4: ue(v). 0 is fine.
66 writer.WriteExponentialGolomb(0); 63 writer.WriteExponentialGolomb(0);
67 // max_num_ref_frames: ue(v). 0 is fine. 64 // max_num_ref_frames: ue(v). 0 is fine.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00, 144 0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00,
148 0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60}; 145 0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60};
149 EXPECT_TRUE( 146 EXPECT_TRUE(
150 static_cast<bool>(sps_ = SpsParser::ParseSps(buffer, arraysize(buffer)))); 147 static_cast<bool>(sps_ = SpsParser::ParseSps(buffer, arraysize(buffer))));
151 EXPECT_EQ(200u, sps_->width); 148 EXPECT_EQ(200u, sps_->width);
152 EXPECT_EQ(400u, sps_->height); 149 EXPECT_EQ(400u, sps_->height);
153 } 150 }
154 151
155 TEST_F(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) { 152 TEST_F(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) {
156 rtc::Buffer buffer; 153 rtc::Buffer buffer;
157 GenerateFakeSps(320u, 180u, 1, &buffer); 154 GenerateFakeSps(320u, 180u, &buffer);
158 EXPECT_TRUE(static_cast<bool>( 155 EXPECT_TRUE(static_cast<bool>(
159 sps_ = SpsParser::ParseSps(buffer.data(), buffer.size()))); 156 sps_ = SpsParser::ParseSps(buffer.data(), buffer.size())));
160 EXPECT_EQ(320u, sps_->width); 157 EXPECT_EQ(320u, sps_->width);
161 EXPECT_EQ(180u, sps_->height); 158 EXPECT_EQ(180u, sps_->height);
162 EXPECT_EQ(1u, sps_->id);
163 } 159 }
164 160
165 TEST_F(H264SpsParserTest, TestSyntheticSPSWeirdResolution) { 161 TEST_F(H264SpsParserTest, TestSyntheticSPSWeirdResolution) {
166 rtc::Buffer buffer; 162 rtc::Buffer buffer;
167 GenerateFakeSps(156u, 122u, 2, &buffer); 163 GenerateFakeSps(156u, 122u, &buffer);
168 EXPECT_TRUE(static_cast<bool>( 164 EXPECT_TRUE(static_cast<bool>(
169 sps_ = SpsParser::ParseSps(buffer.data(), buffer.size()))); 165 sps_ = SpsParser::ParseSps(buffer.data(), buffer.size())));
170 EXPECT_EQ(156u, sps_->width); 166 EXPECT_EQ(156u, sps_->width);
171 EXPECT_EQ(122u, sps_->height); 167 EXPECT_EQ(122u, sps_->height);
172 EXPECT_EQ(2u, sps_->id);
173 } 168 }
174 169
175 } // namespace webrtc 170 } // 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