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

Side by Side Diff: webrtc/modules/video_coding/h264_sps_pps_tracker_unittest.cc

Issue 2754543005: Revert of Save width/height of SPS nalus and restore them on the first packet of an IDR. (Closed)
Patch Set: Created 3 years, 9 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/modules/video_coding/h264_sps_pps_tracker.cc ('k') | no next file » | 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) 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 expected.insert(expected.end(), {1, 2, 3, 2, 1}); 258 expected.insert(expected.end(), {1, 2, 3, 2, 1});
259 259
260 EXPECT_EQ(memcmp(packet.dataPtr, expected.data(), expected.size()), 0); 260 EXPECT_EQ(memcmp(packet.dataPtr, expected.data(), expected.size()), 0);
261 delete[] packet.dataPtr; 261 delete[] packet.dataPtr;
262 } 262 }
263 263
264 TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBand) { 264 TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBand) {
265 constexpr uint8_t kData[] = {1, 2, 3}; 265 constexpr uint8_t kData[] = {1, 2, 3};
266 266
267 // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos. 267 // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos.
268 // width: 320, height: 240
269 const std::vector<uint8_t> sps( 268 const std::vector<uint8_t> sps(
270 {0x67, 0x7a, 0x00, 0x0d, 0xbc, 0xd9, 0x41, 0x41, 0xfa, 0x10, 0x00, 0x00, 269 {0x67, 0x7a, 0x00, 0x0d, 0xbc, 0xd9, 0x41, 0x41, 0xfa, 0x10, 0x00, 0x00,
271 0x03, 0x00, 0x10, 0x00, 0x00, 0x03, 0x03, 0xc0, 0xf1, 0x42, 0x99, 0x60}); 270 0x03, 0x00, 0x10, 0x00, 0x00, 0x03, 0x03, 0xc0, 0xf1, 0x42, 0x99, 0x60});
272 const std::vector<uint8_t> pps({0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0}); 271 const std::vector<uint8_t> pps({0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0});
273 tracker_.InsertSpsPpsNalus(sps, pps); 272 tracker_.InsertSpsPpsNalus(sps, pps);
274 273
275 // Insert first packet of the IDR. 274 // Insert first packet of the IDR.
276 VCMPacket idr_packet = GetDefaultPacket(); 275 VCMPacket idr_packet = GetDefaultPacket();
277 idr_packet.video_header.is_first_packet_in_frame = true; 276 idr_packet.video_header.is_first_packet_in_frame = true;
278 AddIdr(&idr_packet, 0); 277 AddIdr(&idr_packet, 0);
279 idr_packet.dataPtr = kData; 278 idr_packet.dataPtr = kData;
280 idr_packet.sizeBytes = sizeof(kData); 279 idr_packet.sizeBytes = sizeof(kData);
281 EXPECT_EQ(H264SpsPpsTracker::kInsert, 280 EXPECT_EQ(H264SpsPpsTracker::kInsert,
282 tracker_.CopyAndFixBitstream(&idr_packet)); 281 tracker_.CopyAndFixBitstream(&idr_packet));
283 EXPECT_EQ(320, idr_packet.width);
284 EXPECT_EQ(240, idr_packet.height);
285 if (idr_packet.dataPtr != kData) { 282 if (idr_packet.dataPtr != kData) {
286 // In case CopyAndFixBitStream() prepends SPS/PPS nalus to the packet, it 283 // In case CopyAndFixBitStream() prepends SPS/PPS nalus to the packet, it
287 // uses new uint8_t[] to allocate memory. Caller of CopyAndFixBitStream() 284 // uses new uint8_t[] to allocate memory. Caller of CopyAndFixBitStream()
288 // needs to take care of freeing the memory. 285 // needs to take care of freeing the memory.
289 delete[] idr_packet.dataPtr; 286 delete[] idr_packet.dataPtr;
290 } 287 }
291 } 288 }
292 289
293 TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandWrongNaluHeader) { 290 TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandWrongNaluHeader) {
294 constexpr uint8_t kData[] = {1, 2, 3}; 291 constexpr uint8_t kData[] = {1, 2, 3};
(...skipping 28 matching lines...) Expand all
323 // Insert first packet of the IDR. 320 // Insert first packet of the IDR.
324 VCMPacket idr_packet = GetDefaultPacket(); 321 VCMPacket idr_packet = GetDefaultPacket();
325 idr_packet.video_header.is_first_packet_in_frame = true; 322 idr_packet.video_header.is_first_packet_in_frame = true;
326 AddIdr(&idr_packet, 0); 323 AddIdr(&idr_packet, 0);
327 idr_packet.dataPtr = kData; 324 idr_packet.dataPtr = kData;
328 idr_packet.sizeBytes = sizeof(kData); 325 idr_packet.sizeBytes = sizeof(kData);
329 EXPECT_EQ(H264SpsPpsTracker::kRequestKeyframe, 326 EXPECT_EQ(H264SpsPpsTracker::kRequestKeyframe,
330 tracker_.CopyAndFixBitstream(&idr_packet)); 327 tracker_.CopyAndFixBitstream(&idr_packet));
331 } 328 }
332 329
333 TEST_F(TestH264SpsPpsTracker, SaveRestoreWidthHeight) {
334 std::vector<uint8_t> data;
335
336 // Insert an SPS/PPS packet with width/height and make sure
337 // that information is set on the first IDR packet.
338 VCMPacket sps_pps_packet1 = GetDefaultPacket();
339 AddSps(&sps_pps_packet1, 0, &data);
340 AddPps(&sps_pps_packet1, 0, 1, &data);
341 sps_pps_packet1.dataPtr = data.data();
342 sps_pps_packet1.sizeBytes = data.size();
343 sps_pps_packet1.width = 320;
344 sps_pps_packet1.height = 240;
345 EXPECT_EQ(H264SpsPpsTracker::kDrop,
346 tracker_.CopyAndFixBitstream(&sps_pps_packet1));
347
348 VCMPacket idr_packet1 = GetDefaultPacket();
349 idr_packet1.video_header.is_first_packet_in_frame = true;
350 AddIdr(&idr_packet1, 1);
351 data.insert(data.end(), {1, 2, 3});
352 idr_packet1.dataPtr = data.data();
353 idr_packet1.sizeBytes = data.size();
354 EXPECT_EQ(H264SpsPpsTracker::kInsert,
355 tracker_.CopyAndFixBitstream(&idr_packet1));
356
357 EXPECT_EQ(320, idr_packet1.width);
358 EXPECT_EQ(240, idr_packet1.height);
359 delete[] idr_packet1.dataPtr;
360 }
361
362 } // namespace video_coding 330 } // namespace video_coding
363 } // namespace webrtc 331 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/h264_sps_pps_tracker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698