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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc

Issue 1406283008: Update reference indices according to updates in the RTP payload profile. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: updated comments and added todo Created 5 years, 1 month 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/rtp_rtcp/source/rtp_format_vp9.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) 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // 0 1 2 3 4 5 6 7 90 // 0 1 2 3 4 5 6 7
91 // +-+-+-+-+-+-+-+-+ 91 // +-+-+-+-+-+-+-+-+
92 // |I|P|L|F|B|E|V|-| (REQUIRED) 92 // |I|P|L|F|B|E|V|-| (REQUIRED)
93 // +-+-+-+-+-+-+-+-+ 93 // +-+-+-+-+-+-+-+-+
94 // I: |M| PICTURE ID | (RECOMMENDED) 94 // I: |M| PICTURE ID | (RECOMMENDED)
95 // +-+-+-+-+-+-+-+-+ 95 // +-+-+-+-+-+-+-+-+
96 // M: | EXTENDED PID | (RECOMMENDED) 96 // M: | EXTENDED PID | (RECOMMENDED)
97 // +-+-+-+-+-+-+-+-+ 97 // +-+-+-+-+-+-+-+-+
98 // L: | T |U| S |D| (CONDITIONALLY RECOMMENDED) 98 // L: | T |U| S |D| (CONDITIONALLY RECOMMENDED)
99 // +-+-+-+-+-+-+-+-+ -| 99 // +-+-+-+-+-+-+-+-+ -|
100 // P,F: | P_DIFF |X|N| (CONDITIONALLY RECOMMENDED) . 100 // P,F: | P_DIFF |N| (CONDITIONALLY RECOMMENDED) . up to 3 times
101 // +-+-+-+-+-+-+-+-+ . up to 3 times
102 // X: |EXTENDED P_DIFF| (OPTIONAL) .
103 // +-+-+-+-+-+-+-+-+ -| 101 // +-+-+-+-+-+-+-+-+ -|
104 // V: | SS | 102 // V: | SS |
105 // | .. | 103 // | .. |
106 // +-+-+-+-+-+-+-+-+ 104 // +-+-+-+-+-+-+-+-+
107 // 105 //
108 // Payload descriptor for non-flexible mode 106 // Payload descriptor for non-flexible mode
109 // 0 1 2 3 4 5 6 7 107 // 0 1 2 3 4 5 6 7
110 // +-+-+-+-+-+-+-+-+ 108 // +-+-+-+-+-+-+-+-+
111 // |I|P|L|F|B|E|V|-| (REQUIRED) 109 // |I|P|L|F|B|E|V|-| (REQUIRED)
112 // +-+-+-+-+-+-+-+-+ 110 // +-+-+-+-+-+-+-+-+
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // I:0, P:0, L:1, F:1, B:1, E:1, V:0 (2hdr + 21 payload) 289 // I:0, P:0, L:1, F:1, B:1, E:1, V:0 (2hdr + 21 payload)
292 // L: T:3, U:1, S:2, D:0 290 // L: T:3, U:1, S:2, D:0
293 const size_t kExpectedHdrSizes[] = {2}; 291 const size_t kExpectedHdrSizes[] = {2};
294 const size_t kExpectedSizes[] = {23}; 292 const size_t kExpectedSizes[] = {23};
295 const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); 293 const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
296 CreateParseAndCheckPackets(kExpectedHdrSizes, kExpectedSizes, kExpectedNum); 294 CreateParseAndCheckPackets(kExpectedHdrSizes, kExpectedSizes, kExpectedNum);
297 } 295 }
298 296
299 TEST_F(RtpPacketizerVp9Test, TestRefIdx) { 297 TEST_F(RtpPacketizerVp9Test, TestRefIdx) {
300 const size_t kFrameSize = 16; 298 const size_t kFrameSize = 16;
301 const size_t kPacketSize = 22; 299 const size_t kPacketSize = 21;
302 300
303 expected_.inter_pic_predicted = true; // P 301 expected_.inter_pic_predicted = true; // P
304 expected_.flexible_mode = true; // F 302 expected_.flexible_mode = true; // F
305 expected_.picture_id = 100; 303 expected_.picture_id = 2;
306 expected_.num_ref_pics = 2; 304 expected_.max_picture_id = kMaxOneBytePictureId;
307 expected_.pid_diff[0] = 3; 305
308 expected_.pid_diff[1] = 1171; 306 expected_.num_ref_pics = 3;
309 expected_.ref_picture_id[0] = 97; // 100 - 3 = 97 307 expected_.pid_diff[0] = 1;
310 expected_.ref_picture_id[1] = 31697; // 0x7FFF + 1 + 100 - 1171 = 31697 308 expected_.pid_diff[1] = 3;
309 expected_.pid_diff[2] = 127;
310 expected_.ref_picture_id[0] = 1; // 2 - 1 = 1
311 expected_.ref_picture_id[1] = 127; // (kMaxPictureId + 1) + 2 - 3 = 127
312 expected_.ref_picture_id[2] = 3; // (kMaxPictureId + 1) + 2 - 127 = 3
311 Init(kFrameSize, kPacketSize); 313 Init(kFrameSize, kPacketSize);
312 314
313 // Two packets: 315 // Two packets:
314 // I:1, P:1, L:0, F:1, B:1, E:1, V:0 (6hdr + 16 payload) 316 // I:1, P:1, L:0, F:1, B:1, E:1, V:0 (5hdr + 16 payload)
315 // I: 100 (2 bytes) 317 // I: 2
316 // P,F: P_DIFF:3, X:0, N:1 318 // P,F: P_DIFF:1, N:1
317 // P_DIFF:1171, X:1, N:0 (2 bytes) 319 // P_DIFF:3, N:1
318 const size_t kExpectedHdrSizes[] = {6}; 320 // P_DIFF:127, N:0
319 const size_t kExpectedSizes[] = {22}; 321 const size_t kExpectedHdrSizes[] = {5};
322 const size_t kExpectedSizes[] = {21};
320 const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); 323 const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
321 CreateParseAndCheckPackets(kExpectedHdrSizes, kExpectedSizes, kExpectedNum); 324 CreateParseAndCheckPackets(kExpectedHdrSizes, kExpectedSizes, kExpectedNum);
322 } 325 }
323 326
324 TEST_F(RtpPacketizerVp9Test, TestRefIdxFailsWithoutPictureId) { 327 TEST_F(RtpPacketizerVp9Test, TestRefIdxFailsWithoutPictureId) {
325 const size_t kFrameSize = 16; 328 const size_t kFrameSize = 16;
326 const size_t kPacketSize = 22; 329 const size_t kPacketSize = 21;
327 330
328 expected_.inter_pic_predicted = true; 331 expected_.inter_pic_predicted = true;
329 expected_.flexible_mode = true; 332 expected_.flexible_mode = true;
330 expected_.num_ref_pics = 1; 333 expected_.num_ref_pics = 1;
331 expected_.pid_diff[0] = 3; 334 expected_.pid_diff[0] = 3;
332 Init(kFrameSize, kPacketSize); 335 Init(kFrameSize, kPacketSize);
333 336
334 const size_t kExpectedNum = 0; 337 const size_t kExpectedNum = 0;
335 CreateParseAndCheckPackets(NULL, NULL, kExpectedNum); 338 CreateParseAndCheckPackets(NULL, NULL, kExpectedNum);
336 } 339 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 expected_.beginning_of_frame = true; 515 expected_.beginning_of_frame = true;
513 expected_.flexible_mode = true; 516 expected_.flexible_mode = true;
514 expected_.temporal_idx = kTemporalIdx; 517 expected_.temporal_idx = kTemporalIdx;
515 expected_.temporal_up_switch = kUbit ? true : false; 518 expected_.temporal_up_switch = kUbit ? true : false;
516 expected_.spatial_idx = kSpatialIdx; 519 expected_.spatial_idx = kSpatialIdx;
517 expected_.inter_layer_predicted = kDbit ? true : false; 520 expected_.inter_layer_predicted = kDbit ? true : false;
518 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet)); 521 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet));
519 } 522 }
520 523
521 TEST_F(RtpDepacketizerVp9Test, ParseRefIdx) { 524 TEST_F(RtpDepacketizerVp9Test, ParseRefIdx) {
522 const uint8_t kHeaderLength = 7; 525 const uint8_t kHeaderLength = 6;
523 const int16_t kPictureId = 17; 526 const int16_t kPictureId = 17;
524 const int16_t kPdiff1 = 17; 527 const int16_t kPdiff1 = 17;
525 const int16_t kPdiff2 = 18; 528 const int16_t kPdiff2 = 18;
526 const int16_t kExtPdiff3 = 2171; 529 const int16_t kPdiff3 = 127;
527 uint8_t packet[13] = {0}; 530 uint8_t packet[13] = {0};
528 packet[0] = 0xD8; // I:1 P:1 L:0 F:1 B:1 E:0 V:0 R:0 531 packet[0] = 0xD8; // I:1 P:1 L:0 F:1 B:1 E:0 V:0 R:0
529 packet[1] = 0x80 | ((kPictureId >> 8) & 0x7F); // Two byte pictureID. 532 packet[1] = 0x80 | ((kPictureId >> 8) & 0x7F); // Two byte pictureID.
530 packet[2] = kPictureId; 533 packet[2] = kPictureId;
531 packet[3] = (kPdiff1 << 2) | (0 << 1) | 1; // P_DIFF X:0 N:1 534 packet[3] = (kPdiff1 << 1) | 1; // P_DIFF N:1
532 packet[4] = (kPdiff2 << 2) | (0 << 1) | 1; // P_DIFF X:0 N:1 535 packet[4] = (kPdiff2 << 1) | 1; // P_DIFF N:1
533 packet[5] = ((kExtPdiff3 >> 8) << 2) | (1 << 1) | 0; // P_DIFF X:1 N:0 536 packet[5] = (kPdiff3 << 1) | 0; // P_DIFF N:0
534 packet[6] = kExtPdiff3 & 0xff; // EXTENDED P_DIFF
535 537
536 // I:1 P:1 L:0 F:1 B:1 E:0 V:0 538 // I:1 P:1 L:0 F:1 B:1 E:0 V:0
537 // I: PICTURE ID:17 539 // I: PICTURE ID:17
538 // I: 540 // I:
539 // P,F: P_DIFF:17 X:0 N:1 => refPictureId = 17 - 17 = 0 541 // P,F: P_DIFF:17 N:1 => refPicId = 17 - 17 = 0
540 // P,F: P_DIFF:18 X:0 N:1 => refPictureId = 0x7FFF + 1 + 17 - 18 = 0x7FFF 542 // P,F: P_DIFF:18 N:1 => refPicId = (kMaxPictureId + 1) + 17 - 18 = 0x7FFF
541 // P,F: P_DIFF:2171 X:1 N:0 => refPictureId = 0x7FFF + 1 + 17 - 2171 = 30614 543 // P,F: P_DIFF:127 N:0 => refPicId = (kMaxPictureId + 1) + 17 - 127 = 32658
542 expected_.beginning_of_frame = true; 544 expected_.beginning_of_frame = true;
543 expected_.inter_pic_predicted = true; 545 expected_.inter_pic_predicted = true;
544 expected_.flexible_mode = true; 546 expected_.flexible_mode = true;
545 expected_.picture_id = kPictureId; 547 expected_.picture_id = kPictureId;
546 expected_.num_ref_pics = 3; 548 expected_.num_ref_pics = 3;
547 expected_.pid_diff[0] = kPdiff1; 549 expected_.pid_diff[0] = kPdiff1;
548 expected_.pid_diff[1] = kPdiff2; 550 expected_.pid_diff[1] = kPdiff2;
549 expected_.pid_diff[2] = kExtPdiff3; 551 expected_.pid_diff[2] = kPdiff3;
550 expected_.ref_picture_id[0] = 0; 552 expected_.ref_picture_id[0] = 0;
551 expected_.ref_picture_id[1] = 0x7FFF; 553 expected_.ref_picture_id[1] = 0x7FFF;
552 expected_.ref_picture_id[2] = 30614; 554 expected_.ref_picture_id[2] = 32658;
553 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet)); 555 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet));
554 } 556 }
555 557
556 TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithNoPictureId) { 558 TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithNoPictureId) {
557 const int16_t kPdiff = 3; 559 const int16_t kPdiff = 3;
558 uint8_t packet[13] = {0}; 560 uint8_t packet[13] = {0};
559 packet[0] = 0x58; // I:0 P:1 L:0 F:1 B:1 E:0 V:0 R:0 561 packet[0] = 0x58; // I:0 P:1 L:0 F:1 B:1 E:0 V:0 R:0
560 packet[1] = (kPdiff << 2) | (0 << 1) | 0; // P,F: P_DIFF:3 X:0 N:0 562 packet[1] = (kPdiff << 1); // P,F: P_DIFF:3 N:0
561 563
562 RtpDepacketizer::ParsedPayload parsed; 564 RtpDepacketizer::ParsedPayload parsed;
563 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); 565 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet)));
564 } 566 }
565 567
566 TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithTooManyRefPics) { 568 TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithTooManyRefPics) {
567 const int16_t kPdiff = 3; 569 const int16_t kPdiff = 3;
568 uint8_t packet[13] = {0}; 570 uint8_t packet[13] = {0};
569 packet[0] = 0xD8; // I:1 P:1 L:0 F:1 B:1 E:0 V:0 R:0 571 packet[0] = 0xD8; // I:1 P:1 L:0 F:1 B:1 E:0 V:0 R:0
570 packet[1] = kMaxOneBytePictureId; // I: PICTURE ID:127 572 packet[1] = kMaxOneBytePictureId; // I: PICTURE ID:127
571 packet[2] = (kPdiff << 2) | (0 << 1) | 1; // P,F: P_DIFF:3 X:0 N:1 573 packet[2] = (kPdiff << 1) | 1; // P,F: P_DIFF:3 N:1
572 packet[3] = (kPdiff << 2) | (0 << 1) | 1; // P,F: P_DIFF:3 X:0 N:1 574 packet[3] = (kPdiff << 1) | 1; // P,F: P_DIFF:3 N:1
573 packet[4] = (kPdiff << 2) | (0 << 1) | 1; // P,F: P_DIFF:3 X:0 N:1 575 packet[4] = (kPdiff << 1) | 1; // P,F: P_DIFF:3 N:1
574 packet[5] = (kPdiff << 2) | (0 << 1) | 0; // P,F: P_DIFF:3 X:0 N:0 576 packet[5] = (kPdiff << 1) | 0; // P,F: P_DIFF:3 N:0
575 577
576 RtpDepacketizer::ParsedPayload parsed; 578 RtpDepacketizer::ParsedPayload parsed;
577 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); 579 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet)));
578 } 580 }
579 581
580 TEST_F(RtpDepacketizerVp9Test, ParseSsData) { 582 TEST_F(RtpDepacketizerVp9Test, ParseSsData) {
581 const uint8_t kHeaderLength = 5; 583 const uint8_t kHeaderLength = 5;
582 const uint8_t kYbit = 0; 584 const uint8_t kYbit = 0;
583 const size_t kNs = 2; 585 const size_t kNs = 2;
584 const size_t kNg = 2; 586 const size_t kNg = 2;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 } 655 }
654 656
655 TEST_F(RtpDepacketizerVp9Test, ParseFailsForTooShortBufferToFitPayload) { 657 TEST_F(RtpDepacketizerVp9Test, ParseFailsForTooShortBufferToFitPayload) {
656 const uint8_t kHeaderLength = 1; 658 const uint8_t kHeaderLength = 1;
657 uint8_t packet[kHeaderLength] = {0}; 659 uint8_t packet[kHeaderLength] = {0};
658 RtpDepacketizer::ParsedPayload parsed; 660 RtpDepacketizer::ParsedPayload parsed;
659 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); 661 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet)));
660 } 662 }
661 663
662 } // namespace webrtc 664 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_format_vp9.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698