OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 fprintf(fp_mask_, "\n"); | 723 fprintf(fp_mask_, "\n"); |
724 } | 724 } |
725 fprintf(fp_mask_, "\n"); | 725 fprintf(fp_mask_, "\n"); |
726 } | 726 } |
727 | 727 |
728 int ProcessXORPacketMasks(CodeType code_type, | 728 int ProcessXORPacketMasks(CodeType code_type, |
729 FecMaskType fec_mask_type) { | 729 FecMaskType fec_mask_type) { |
730 int code_index = 0; | 730 int code_index = 0; |
731 // Maximum number of media packets allowed for the mask type. | 731 // Maximum number of media packets allowed for the mask type. |
732 const int packet_mask_max = kMaxMediaPackets[fec_mask_type]; | 732 const int packet_mask_max = kMaxMediaPackets[fec_mask_type]; |
733 uint8_t* packet_mask = new uint8_t[packet_mask_max * kMaskSizeLBitSet]; | 733 std::unique_ptr<uint8_t[]> packet_mask( |
| 734 new uint8_t[packet_mask_max * kUlpfecMaxPacketMaskSize]); |
734 // Loop through codes up to |kMaxMediaPacketsTest|. | 735 // Loop through codes up to |kMaxMediaPacketsTest|. |
735 for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest; | 736 for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest; |
736 num_media_packets++) { | 737 num_media_packets++) { |
737 const int mask_bytes_fec_packet = | 738 const int mask_bytes_fec_packet = |
738 (num_media_packets > 16) ? kMaskSizeLBitSet : kMaskSizeLBitClear; | 739 static_cast<int>(internal::PacketMaskSize(num_media_packets)); |
739 internal::PacketMaskTable mask_table(fec_mask_type, num_media_packets); | 740 internal::PacketMaskTable mask_table(fec_mask_type, num_media_packets); |
740 for (int num_fec_packets = 1; num_fec_packets <= num_media_packets; | 741 for (int num_fec_packets = 1; num_fec_packets <= num_media_packets; |
741 num_fec_packets++) { | 742 num_fec_packets++) { |
742 memset(packet_mask, 0, num_media_packets * mask_bytes_fec_packet); | 743 memset(packet_mask.get(), 0, num_media_packets * mask_bytes_fec_packet); |
743 memcpy(packet_mask, mask_table.fec_packet_mask_table() | 744 memcpy(packet_mask.get(), |
744 [num_media_packets - 1][num_fec_packets - 1], | 745 mask_table.fec_packet_mask_table()[num_media_packets - 1] |
| 746 [num_fec_packets - 1], |
745 num_fec_packets * mask_bytes_fec_packet); | 747 num_fec_packets * mask_bytes_fec_packet); |
746 // Convert to bit mask. | 748 // Convert to bit mask. |
747 GetPacketMaskConvertToBitMask(packet_mask, | 749 GetPacketMaskConvertToBitMask(packet_mask.get(), num_media_packets, |
748 num_media_packets, | 750 num_fec_packets, mask_bytes_fec_packet, |
749 num_fec_packets, | |
750 mask_bytes_fec_packet, | |
751 code_type); | 751 code_type); |
752 if (RejectInvalidMasks(num_media_packets, num_fec_packets) < 0) { | 752 if (RejectInvalidMasks(num_media_packets, num_fec_packets) < 0) { |
753 return -1; | 753 return -1; |
754 } | 754 } |
755 // Compute the metrics for this code/mask. | 755 // Compute the metrics for this code/mask. |
756 ComputeMetricsForCode(code_type, | 756 ComputeMetricsForCode(code_type, |
757 code_index); | 757 code_index); |
758 code_index++; | 758 code_index++; |
759 } | 759 } |
760 } | 760 } |
761 assert(code_index == kNumberCodes); | 761 assert(code_index == kNumberCodes); |
762 delete [] packet_mask; | |
763 return 0; | 762 return 0; |
764 } | 763 } |
765 | 764 |
766 void ProcessRS(CodeType code_type) { | 765 void ProcessRS(CodeType code_type) { |
767 int code_index = 0; | 766 int code_index = 0; |
768 for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest; | 767 for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest; |
769 num_media_packets++) { | 768 num_media_packets++) { |
770 for (int num_fec_packets = 1; num_fec_packets <= num_media_packets; | 769 for (int num_fec_packets = 1; num_fec_packets <= num_media_packets; |
771 num_fec_packets++) { | 770 num_fec_packets++) { |
772 // Compute the metrics for this code type. | 771 // Compute the metrics for this code type. |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 recovery_rate_per_loss[loss_number], | 1072 recovery_rate_per_loss[loss_number], |
1074 kRecoveryRateXorRandom[2]); | 1073 kRecoveryRateXorRandom[2]); |
1075 EXPECT_GE(kMetricsXorBursty[code_index]. | 1074 EXPECT_GE(kMetricsXorBursty[code_index]. |
1076 recovery_rate_per_loss[loss_number], | 1075 recovery_rate_per_loss[loss_number], |
1077 kRecoveryRateXorBursty[2]); | 1076 kRecoveryRateXorBursty[2]); |
1078 } | 1077 } |
1079 } | 1078 } |
1080 } | 1079 } |
1081 | 1080 |
1082 } // namespace webrtc | 1081 } // namespace webrtc |
OLD | NEW |