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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/h264/sps_parser_unittest.cc

Issue 1979443004: Add H264 bitstream rewriting to limit frame reordering marker in header (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rewriting on the receiver side as well Created 4 years, 7 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
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
11 #include "webrtc/modules/rtp_rtcp/source/h264_sps_parser.h" 11 #include "webrtc/modules/rtp_rtcp/source/h264/sps_parser.h"
12 12
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #include "webrtc/base/arraysize.h" 15 #include "webrtc/base/arraysize.h"
16 #include "webrtc/base/bitbuffer.h" 16 #include "webrtc/base/bitbuffer.h"
17 17
18 namespace webrtc { 18 namespace webrtc {
19 19
20 // Example SPS can be generated with ffmpeg. Here's an example set of commands, 20 // Example SPS can be generated with ffmpeg. Here's an example set of commands,
21 // runnable on OS X: 21 // runnable on OS X:
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 } 116 }
117 } 117 }
118 118
119 TEST(H264SpsParserTest, TestSampleSPSHdLandscape) { 119 TEST(H264SpsParserTest, TestSampleSPSHdLandscape) {
120 // SPS for a 1280x720 camera capture from ffmpeg on osx. Contains 120 // SPS for a 1280x720 camera capture from ffmpeg on osx. Contains
121 // emulation bytes but no cropping. 121 // emulation bytes but no cropping.
122 const uint8_t buffer[] = {0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05, 122 const uint8_t buffer[] = {0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05,
123 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00, 123 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00,
124 0x00, 0x2A, 0xE0, 0xF1, 0x83, 0x19, 0x60}; 124 0x00, 0x2A, 0xE0, 0xF1, 0x83, 0x19, 0x60};
125 H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer)); 125 SpsParser parser = SpsParser(buffer, arraysize(buffer));
126 EXPECT_TRUE(parser.Parse()); 126 EXPECT_TRUE(parser.Parse());
127 EXPECT_EQ(1280u, parser.width()); 127 EXPECT_EQ(1280u, parser.GetState()->width);
128 EXPECT_EQ(720u, parser.height()); 128 EXPECT_EQ(720u, parser.GetState()->height);
129 } 129 }
130 130
131 TEST(H264SpsParserTest, TestSampleSPSVgaLandscape) { 131 TEST(H264SpsParserTest, TestSampleSPSVgaLandscape) {
132 // SPS for a 640x360 camera capture from ffmpeg on osx. Contains emulation 132 // SPS for a 640x360 camera capture from ffmpeg on osx. Contains emulation
133 // bytes and cropping (360 isn't divisible by 16). 133 // bytes and cropping (360 isn't divisible by 16).
134 const uint8_t buffer[] = {0x7A, 0x00, 0x1E, 0xBC, 0xD9, 0x40, 0xA0, 0x2F, 134 const uint8_t buffer[] = {0x7A, 0x00, 0x1E, 0xBC, 0xD9, 0x40, 0xA0, 0x2F,
135 0xF8, 0x98, 0x40, 0x00, 0x00, 0x03, 0x01, 0x80, 135 0xF8, 0x98, 0x40, 0x00, 0x00, 0x03, 0x01, 0x80,
136 0x00, 0x00, 0x56, 0x83, 0xC5, 0x8B, 0x65, 0x80}; 136 0x00, 0x00, 0x56, 0x83, 0xC5, 0x8B, 0x65, 0x80};
137 H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer)); 137 SpsParser parser = SpsParser(buffer, arraysize(buffer));
138 EXPECT_TRUE(parser.Parse()); 138 EXPECT_TRUE(parser.Parse());
139 EXPECT_EQ(640u, parser.width()); 139 EXPECT_EQ(640u, parser.GetState()->width);
140 EXPECT_EQ(360u, parser.height()); 140 EXPECT_EQ(360u, parser.GetState()->height);
141 } 141 }
142 142
143 TEST(H264SpsParserTest, TestSampleSPSWeirdResolution) { 143 TEST(H264SpsParserTest, TestSampleSPSWeirdResolution) {
144 // SPS for a 200x400 camera capture from ffmpeg on osx. Horizontal and 144 // SPS for a 200x400 camera capture from ffmpeg on osx. Horizontal and
145 // veritcal crop (neither dimension is divisible by 16). 145 // veritcal crop (neither dimension is divisible by 16).
146 const uint8_t buffer[] = {0x7A, 0x00, 0x0D, 0xBC, 0xD9, 0x43, 0x43, 0x3E, 146 const uint8_t buffer[] = {0x7A, 0x00, 0x0D, 0xBC, 0xD9, 0x43, 0x43, 0x3E,
147 0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00, 147 0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00,
148 0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60}; 148 0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60};
149 H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer)); 149 SpsParser parser = SpsParser(buffer, arraysize(buffer));
150 EXPECT_TRUE(parser.Parse()); 150 EXPECT_TRUE(parser.Parse());
151 EXPECT_EQ(200u, parser.width()); 151 EXPECT_EQ(200u, parser.GetState()->width);
152 EXPECT_EQ(400u, parser.height()); 152 EXPECT_EQ(400u, parser.GetState()->height);
153 } 153 }
154 154
155 TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) { 155 TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) {
156 uint8_t buffer[kSpsBufferMaxSize] = {0}; 156 uint8_t buffer[kSpsBufferMaxSize] = {0};
157 GenerateFakeSps(320u, 180u, buffer); 157 GenerateFakeSps(320u, 180u, buffer);
158 H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer)); 158 SpsParser parser = SpsParser(buffer, arraysize(buffer));
159 EXPECT_TRUE(parser.Parse()); 159 EXPECT_TRUE(parser.Parse());
160 EXPECT_EQ(320u, parser.width()); 160 EXPECT_EQ(320u, parser.GetState()->width);
161 EXPECT_EQ(180u, parser.height()); 161 EXPECT_EQ(180u, parser.GetState()->height);
162 } 162 }
163 163
164 TEST(H264SpsParserTest, TestSyntheticSPSWeirdResolution) { 164 TEST(H264SpsParserTest, TestSyntheticSPSWeirdResolution) {
165 uint8_t buffer[kSpsBufferMaxSize] = {0}; 165 uint8_t buffer[kSpsBufferMaxSize] = {0};
166 GenerateFakeSps(156u, 122u, buffer); 166 GenerateFakeSps(156u, 122u, buffer);
167 H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer)); 167 SpsParser parser = SpsParser(buffer, arraysize(buffer));
168 EXPECT_TRUE(parser.Parse()); 168 EXPECT_TRUE(parser.Parse());
169 EXPECT_EQ(156u, parser.width()); 169 EXPECT_EQ(156u, parser.GetState()->width);
170 EXPECT_EQ(122u, parser.height()); 170 EXPECT_EQ(122u, parser.GetState()->height);
171 } 171 }
172 172
173 } // namespace webrtc 173 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698