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

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

Issue 2651593004: Reland of "H264SpsPpsTracker.InsertSpsPpsNalus() should accept Nalus with header. (Closed)
Patch Set: Comment. Created 3 years, 11 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) 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 expected.insert(expected.end(), {H264::NaluType::kSps, 13}); 254 expected.insert(expected.end(), {H264::NaluType::kSps, 13});
255 expected.insert(expected.end(), start_code, start_code + sizeof(start_code)); 255 expected.insert(expected.end(), start_code, start_code + sizeof(start_code));
256 expected.insert(expected.end(), {H264::NaluType::kPps, 27}); 256 expected.insert(expected.end(), {H264::NaluType::kPps, 27});
257 expected.insert(expected.end(), start_code, start_code + sizeof(start_code)); 257 expected.insert(expected.end(), start_code, start_code + sizeof(start_code));
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) {
265 constexpr uint8_t kData[] = {1, 2, 3};
266
267 // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos.
268 const std::vector<uint8_t> sps(
269 {0x67, 0x7a, 0x00, 0x0d, 0xbc, 0xd9, 0x41, 0x41, 0xfa, 0x10, 0x00, 0x00,
270 0x03, 0x00, 0x10, 0x00, 0x00, 0x03, 0x03, 0xc0, 0xf1, 0x42, 0x99, 0x60});
271 const std::vector<uint8_t> pps({0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0});
272 tracker_.InsertSpsPpsNalus(sps, pps);
273
274 // Insert first packet of the IDR.
275 VCMPacket idr_packet = GetDefaultPacket();
276 idr_packet.video_header.is_first_packet_in_frame = true;
277 AddIdr(&idr_packet, 0);
278 idr_packet.dataPtr = kData;
279 idr_packet.sizeBytes = sizeof(kData);
280 EXPECT_EQ(H264SpsPpsTracker::kInsert,
281 tracker_.CopyAndFixBitstream(&idr_packet));
282 if (idr_packet.dataPtr != kData) {
283 // In case CopyAndFixBitStream() prepends SPS/PPS nalus to the packet, it
284 // uses new uint8_t[] to allocate memory. Caller of CopyAndFixBitStream()
285 // needs to take care of freeing the memory.
286 delete[] idr_packet.dataPtr;
287 }
288 }
289
290 TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandWrongNaluHeader) {
291 constexpr uint8_t kData[] = {1, 2, 3};
292
293 // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos.
294 // Nalu headers manupilated afterwards.
295 const std::vector<uint8_t> sps(
296 {0xff, 0x7a, 0x00, 0x0d, 0xbc, 0xd9, 0x41, 0x41, 0xfa, 0x10, 0x00, 0x00,
297 0x03, 0x00, 0x10, 0x00, 0x00, 0x03, 0x03, 0xc0, 0xf1, 0x42, 0x99, 0x60});
298 const std::vector<uint8_t> pps({0xff, 0xeb, 0xe3, 0xcb, 0x22, 0xc0});
299 tracker_.InsertSpsPpsNalus(sps, pps);
300
301 // Insert first packet of the IDR.
302 VCMPacket idr_packet = GetDefaultPacket();
303 idr_packet.video_header.is_first_packet_in_frame = true;
304 AddIdr(&idr_packet, 0);
305 idr_packet.dataPtr = kData;
306 idr_packet.sizeBytes = sizeof(kData);
307 EXPECT_EQ(H264SpsPpsTracker::kRequestKeyframe,
308 tracker_.CopyAndFixBitstream(&idr_packet));
309 }
310
311 TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandIncompleteNalu) {
312 constexpr uint8_t kData[] = {1, 2, 3};
313
314 // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos.
315 // Nalus damaged afterwards.
316 const std::vector<uint8_t> sps({0x67, 0x7a, 0x00, 0x0d, 0xbc, 0xd9});
317 const std::vector<uint8_t> pps({0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0});
318 tracker_.InsertSpsPpsNalus(sps, pps);
319
320 // Insert first packet of the IDR.
321 VCMPacket idr_packet = GetDefaultPacket();
322 idr_packet.video_header.is_first_packet_in_frame = true;
323 AddIdr(&idr_packet, 0);
324 idr_packet.dataPtr = kData;
325 idr_packet.sizeBytes = sizeof(kData);
326 EXPECT_EQ(H264SpsPpsTracker::kRequestKeyframe,
327 tracker_.CopyAndFixBitstream(&idr_packet));
328 }
329
264 } // namespace video_coding 330 } // namespace video_coding
265 } // namespace webrtc 331 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/h264_sps_pps_tracker.cc ('k') | webrtc/video/rtp_stream_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698