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

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

Issue 2649113003: Revert of H264SpsPpsTracker.InsertSpsPpsNalus() should accept Nalus with header. (Closed)
Patch Set: 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 }
283
284 TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandWrongNaluHeader) {
285 constexpr uint8_t kData[] = {1, 2, 3};
286
287 // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos.
288 // Nalu headers manupilated afterwards.
289 const std::vector<uint8_t> sps(
290 {0xff, 0x7a, 0x00, 0x0d, 0xbc, 0xd9, 0x41, 0x41, 0xfa, 0x10, 0x00, 0x00,
291 0x03, 0x00, 0x10, 0x00, 0x00, 0x03, 0x03, 0xc0, 0xf1, 0x42, 0x99, 0x60});
292 const std::vector<uint8_t> pps({0xff, 0xeb, 0xe3, 0xcb, 0x22, 0xc0});
293 tracker_.InsertSpsPpsNalus(sps, pps);
294
295 // Insert first packet of the IDR.
296 VCMPacket idr_packet = GetDefaultPacket();
297 idr_packet.video_header.is_first_packet_in_frame = true;
298 AddIdr(&idr_packet, 0);
299 idr_packet.dataPtr = kData;
300 idr_packet.sizeBytes = sizeof(kData);
301 EXPECT_EQ(H264SpsPpsTracker::kRequestKeyframe,
302 tracker_.CopyAndFixBitstream(&idr_packet));
303 }
304
305 TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandIncompleteNalu) {
306 constexpr uint8_t kData[] = {1, 2, 3};
307
308 // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos.
309 // Nalus damaged afterwards.
310 const std::vector<uint8_t> sps({0x67, 0x7a, 0x00, 0x0d, 0xbc, 0xd9});
311 const std::vector<uint8_t> pps({0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0});
312 tracker_.InsertSpsPpsNalus(sps, pps);
313
314 // Insert first packet of the IDR.
315 VCMPacket idr_packet = GetDefaultPacket();
316 idr_packet.video_header.is_first_packet_in_frame = true;
317 AddIdr(&idr_packet, 0);
318 idr_packet.dataPtr = kData;
319 idr_packet.sizeBytes = sizeof(kData);
320 EXPECT_EQ(H264SpsPpsTracker::kRequestKeyframe,
321 tracker_.CopyAndFixBitstream(&idr_packet));
322 }
323
324 } // namespace video_coding 264 } // namespace video_coding
325 } // namespace webrtc 265 } // 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