OLD | NEW |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 EXPECT_EQ(expected.width[i], actual.width[i]); | 48 EXPECT_EQ(expected.width[i], actual.width[i]); |
49 EXPECT_EQ(expected.height[i], actual.height[i]); | 49 EXPECT_EQ(expected.height[i], actual.height[i]); |
50 } | 50 } |
51 } | 51 } |
52 EXPECT_EQ(expected.gof.num_frames_in_gof, actual.gof.num_frames_in_gof); | 52 EXPECT_EQ(expected.gof.num_frames_in_gof, actual.gof.num_frames_in_gof); |
53 for (size_t i = 0; i < expected.gof.num_frames_in_gof; i++) { | 53 for (size_t i = 0; i < expected.gof.num_frames_in_gof; i++) { |
54 EXPECT_EQ(expected.gof.temporal_up_switch[i], | 54 EXPECT_EQ(expected.gof.temporal_up_switch[i], |
55 actual.gof.temporal_up_switch[i]); | 55 actual.gof.temporal_up_switch[i]); |
56 EXPECT_EQ(expected.gof.temporal_idx[i], actual.gof.temporal_idx[i]); | 56 EXPECT_EQ(expected.gof.temporal_idx[i], actual.gof.temporal_idx[i]); |
57 EXPECT_EQ(expected.gof.num_ref_pics[i], actual.gof.num_ref_pics[i]); | 57 EXPECT_EQ(expected.gof.num_ref_pics[i], actual.gof.num_ref_pics[i]); |
58 for (size_t j = 0; j < expected.gof.num_ref_pics[i]; j++) { | 58 for (uint8_t j = 0; j < expected.gof.num_ref_pics[i]; j++) { |
59 EXPECT_EQ(expected.gof.pid_diff[i][j], actual.gof.pid_diff[i][j]); | 59 EXPECT_EQ(expected.gof.pid_diff[i][j], actual.gof.pid_diff[i][j]); |
60 } | 60 } |
61 } | 61 } |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 void VerifyPayload(const RtpDepacketizer::ParsedPayload& parsed, | 65 void VerifyPayload(const RtpDepacketizer::ParsedPayload& parsed, |
66 const uint8_t* payload, | 66 const uint8_t* payload, |
67 size_t payload_length) { | 67 size_t payload_length) { |
68 EXPECT_EQ(payload, parsed.payload); | 68 EXPECT_EQ(payload, parsed.payload); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 expected_.temporal_idx = kTemporalIdx; | 538 expected_.temporal_idx = kTemporalIdx; |
539 expected_.temporal_up_switch = kUbit ? true : false; | 539 expected_.temporal_up_switch = kUbit ? true : false; |
540 expected_.spatial_idx = kSpatialIdx; | 540 expected_.spatial_idx = kSpatialIdx; |
541 expected_.inter_layer_predicted = kDbit ? true : false; | 541 expected_.inter_layer_predicted = kDbit ? true : false; |
542 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet)); | 542 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet)); |
543 } | 543 } |
544 | 544 |
545 TEST_F(RtpDepacketizerVp9Test, ParseRefIdx) { | 545 TEST_F(RtpDepacketizerVp9Test, ParseRefIdx) { |
546 const uint8_t kHeaderLength = 6; | 546 const uint8_t kHeaderLength = 6; |
547 const int16_t kPictureId = 17; | 547 const int16_t kPictureId = 17; |
548 const int16_t kPdiff1 = 17; | 548 const uint8_t kPdiff1 = 17; |
549 const int16_t kPdiff2 = 18; | 549 const uint8_t kPdiff2 = 18; |
550 const int16_t kPdiff3 = 127; | 550 const uint8_t kPdiff3 = 127; |
551 uint8_t packet[13] = {0}; | 551 uint8_t packet[13] = {0}; |
552 packet[0] = 0xD8; // I:1 P:1 L:0 F:1 B:1 E:0 V:0 R:0 | 552 packet[0] = 0xD8; // I:1 P:1 L:0 F:1 B:1 E:0 V:0 R:0 |
553 packet[1] = 0x80 | ((kPictureId >> 8) & 0x7F); // Two byte pictureID. | 553 packet[1] = 0x80 | ((kPictureId >> 8) & 0x7F); // Two byte pictureID. |
554 packet[2] = kPictureId; | 554 packet[2] = kPictureId; |
555 packet[3] = (kPdiff1 << 1) | 1; // P_DIFF N:1 | 555 packet[3] = (kPdiff1 << 1) | 1; // P_DIFF N:1 |
556 packet[4] = (kPdiff2 << 1) | 1; // P_DIFF N:1 | 556 packet[4] = (kPdiff2 << 1) | 1; // P_DIFF N:1 |
557 packet[5] = (kPdiff3 << 1) | 0; // P_DIFF N:0 | 557 packet[5] = (kPdiff3 << 1) | 0; // P_DIFF N:0 |
558 | 558 |
559 // I:1 P:1 L:0 F:1 B:1 E:0 V:0 | 559 // I:1 P:1 L:0 F:1 B:1 E:0 V:0 |
560 // I: PICTURE ID:17 | 560 // I: PICTURE ID:17 |
561 // I: | 561 // I: |
562 // P,F: P_DIFF:17 N:1 => refPicId = 17 - 17 = 0 | 562 // P,F: P_DIFF:17 N:1 => refPicId = 17 - 17 = 0 |
563 // P,F: P_DIFF:18 N:1 => refPicId = (kMaxPictureId + 1) + 17 - 18 = 0x7FFF | 563 // P,F: P_DIFF:18 N:1 => refPicId = (kMaxPictureId + 1) + 17 - 18 = 0x7FFF |
564 // P,F: P_DIFF:127 N:0 => refPicId = (kMaxPictureId + 1) + 17 - 127 = 32658 | 564 // P,F: P_DIFF:127 N:0 => refPicId = (kMaxPictureId + 1) + 17 - 127 = 32658 |
565 expected_.beginning_of_frame = true; | 565 expected_.beginning_of_frame = true; |
566 expected_.inter_pic_predicted = true; | 566 expected_.inter_pic_predicted = true; |
567 expected_.flexible_mode = true; | 567 expected_.flexible_mode = true; |
568 expected_.picture_id = kPictureId; | 568 expected_.picture_id = kPictureId; |
569 expected_.num_ref_pics = 3; | 569 expected_.num_ref_pics = 3; |
570 expected_.pid_diff[0] = kPdiff1; | 570 expected_.pid_diff[0] = kPdiff1; |
571 expected_.pid_diff[1] = kPdiff2; | 571 expected_.pid_diff[1] = kPdiff2; |
572 expected_.pid_diff[2] = kPdiff3; | 572 expected_.pid_diff[2] = kPdiff3; |
573 expected_.ref_picture_id[0] = 0; | 573 expected_.ref_picture_id[0] = 0; |
574 expected_.ref_picture_id[1] = 0x7FFF; | 574 expected_.ref_picture_id[1] = 0x7FFF; |
575 expected_.ref_picture_id[2] = 32658; | 575 expected_.ref_picture_id[2] = 32658; |
576 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet)); | 576 ParseAndCheckPacket(packet, expected_, kHeaderLength, sizeof(packet)); |
577 } | 577 } |
578 | 578 |
579 TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithNoPictureId) { | 579 TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithNoPictureId) { |
580 const int16_t kPdiff = 3; | 580 const uint8_t kPdiff = 3; |
581 uint8_t packet[13] = {0}; | 581 uint8_t packet[13] = {0}; |
582 packet[0] = 0x58; // I:0 P:1 L:0 F:1 B:1 E:0 V:0 R:0 | 582 packet[0] = 0x58; // I:0 P:1 L:0 F:1 B:1 E:0 V:0 R:0 |
583 packet[1] = (kPdiff << 1); // P,F: P_DIFF:3 N:0 | 583 packet[1] = (kPdiff << 1); // P,F: P_DIFF:3 N:0 |
584 | 584 |
585 RtpDepacketizer::ParsedPayload parsed; | 585 RtpDepacketizer::ParsedPayload parsed; |
586 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); | 586 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); |
587 } | 587 } |
588 | 588 |
589 TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithTooManyRefPics) { | 589 TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithTooManyRefPics) { |
590 const int16_t kPdiff = 3; | 590 const uint8_t kPdiff = 3; |
591 uint8_t packet[13] = {0}; | 591 uint8_t packet[13] = {0}; |
592 packet[0] = 0xD8; // I:1 P:1 L:0 F:1 B:1 E:0 V:0 R:0 | 592 packet[0] = 0xD8; // I:1 P:1 L:0 F:1 B:1 E:0 V:0 R:0 |
593 packet[1] = kMaxOneBytePictureId; // I: PICTURE ID:127 | 593 packet[1] = kMaxOneBytePictureId; // I: PICTURE ID:127 |
594 packet[2] = (kPdiff << 1) | 1; // P,F: P_DIFF:3 N:1 | 594 packet[2] = (kPdiff << 1) | 1; // P,F: P_DIFF:3 N:1 |
595 packet[3] = (kPdiff << 1) | 1; // P,F: P_DIFF:3 N:1 | 595 packet[3] = (kPdiff << 1) | 1; // P,F: P_DIFF:3 N:1 |
596 packet[4] = (kPdiff << 1) | 1; // P,F: P_DIFF:3 N:1 | 596 packet[4] = (kPdiff << 1) | 1; // P,F: P_DIFF:3 N:1 |
597 packet[5] = (kPdiff << 1) | 0; // P,F: P_DIFF:3 N:0 | 597 packet[5] = (kPdiff << 1) | 0; // P,F: P_DIFF:3 N:0 |
598 | 598 |
599 RtpDepacketizer::ParsedPayload parsed; | 599 RtpDepacketizer::ParsedPayload parsed; |
600 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); | 600 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 } | 676 } |
677 | 677 |
678 TEST_F(RtpDepacketizerVp9Test, ParseFailsForTooShortBufferToFitPayload) { | 678 TEST_F(RtpDepacketizerVp9Test, ParseFailsForTooShortBufferToFitPayload) { |
679 const uint8_t kHeaderLength = 1; | 679 const uint8_t kHeaderLength = 1; |
680 uint8_t packet[kHeaderLength] = {0}; | 680 uint8_t packet[kHeaderLength] = {0}; |
681 RtpDepacketizer::ParsedPayload parsed; | 681 RtpDepacketizer::ParsedPayload parsed; |
682 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); | 682 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); |
683 } | 683 } |
684 | 684 |
685 } // namespace webrtc | 685 } // namespace webrtc |
OLD | NEW |