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 27 matching lines...) Expand all Loading... |
38 * protection of FEC packets. | 38 * protection of FEC packets. |
39 * | 39 * |
40 * The type of packet/symbol loss models considered in this test are: | 40 * The type of packet/symbol loss models considered in this test are: |
41 * (1) Random loss: Bernoulli process, characterized by the average loss rate. | 41 * (1) Random loss: Bernoulli process, characterized by the average loss rate. |
42 * (2) Bursty loss: Markov chain (Gilbert-Elliot model), characterized by two | 42 * (2) Bursty loss: Markov chain (Gilbert-Elliot model), characterized by two |
43 * parameters: average loss rate and average burst length. | 43 * parameters: average loss rate and average burst length. |
44 */ | 44 */ |
45 | 45 |
46 #include <math.h> | 46 #include <math.h> |
47 | 47 |
| 48 #include <memory> |
| 49 |
48 #include "testing/gtest/include/gtest/gtest.h" | 50 #include "testing/gtest/include/gtest/gtest.h" |
49 #include "webrtc/base/scoped_ptr.h" | |
50 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.h" | 51 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.h" |
51 #include "webrtc/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h
" | 52 #include "webrtc/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h
" |
52 #include "webrtc/test/testsupport/fileutils.h" | 53 #include "webrtc/test/testsupport/fileutils.h" |
53 | 54 |
54 namespace webrtc { | 55 namespace webrtc { |
55 | 56 |
56 // Maximum number of media packets allows for XOR (RFC 5109) code. | 57 // Maximum number of media packets allows for XOR (RFC 5109) code. |
57 enum { kMaxNumberMediaPackets = 48 }; | 58 enum { kMaxNumberMediaPackets = 48 }; |
58 | 59 |
59 // Maximum number of media packets allowed for each mask type. | 60 // Maximum number of media packets allowed for each mask type. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 185 } |
185 return max_gap_loss; | 186 return max_gap_loss; |
186 } | 187 } |
187 | 188 |
188 // Returns the number of recovered media packets for the XOR code, given the | 189 // Returns the number of recovered media packets for the XOR code, given the |
189 // packet mask |fec_packet_masks_|, for the loss state/configuration given by | 190 // packet mask |fec_packet_masks_|, for the loss state/configuration given by |
190 // |state|. | 191 // |state|. |
191 int RecoveredMediaPackets(int num_media_packets, | 192 int RecoveredMediaPackets(int num_media_packets, |
192 int num_fec_packets, | 193 int num_fec_packets, |
193 uint8_t* state) { | 194 uint8_t* state) { |
194 rtc::scoped_ptr<uint8_t[]> state_tmp( | 195 std::unique_ptr<uint8_t[]> state_tmp( |
195 new uint8_t[num_media_packets + num_fec_packets]); | 196 new uint8_t[num_media_packets + num_fec_packets]); |
196 memcpy(state_tmp.get(), state, num_media_packets + num_fec_packets); | 197 memcpy(state_tmp.get(), state, num_media_packets + num_fec_packets); |
197 int num_recovered_packets = 0; | 198 int num_recovered_packets = 0; |
198 bool loop_again = true; | 199 bool loop_again = true; |
199 while (loop_again) { | 200 while (loop_again) { |
200 loop_again = false; | 201 loop_again = false; |
201 bool recovered_new_packet = false; | 202 bool recovered_new_packet = false; |
202 // Check if we can recover anything: loop over all possible FEC packets. | 203 // Check if we can recover anything: loop over all possible FEC packets. |
203 for (int i = 0; i < num_fec_packets; i++) { | 204 for (int i = 0; i < num_fec_packets; i++) { |
204 if (state_tmp[i + num_media_packets] == 0) { | 205 if (state_tmp[i + num_media_packets] == 0) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 sizeof(double) * kNumStatesDistribution); | 379 sizeof(double) * kNumStatesDistribution); |
379 memset(metrics->recovery_rate_per_loss, 0, | 380 memset(metrics->recovery_rate_per_loss, 0, |
380 sizeof(double) * 2 * kMaxMediaPacketsTest + 1); | 381 sizeof(double) * 2 * kMaxMediaPacketsTest + 1); |
381 } | 382 } |
382 | 383 |
383 // Compute the metrics for an FEC code, given by the code type |code_type| | 384 // Compute the metrics for an FEC code, given by the code type |code_type| |
384 // (XOR-random/ bursty or RS), and by the code index |code_index| | 385 // (XOR-random/ bursty or RS), and by the code index |code_index| |
385 // (which containes the code size parameters/protection length). | 386 // (which containes the code size parameters/protection length). |
386 void ComputeMetricsForCode(CodeType code_type, | 387 void ComputeMetricsForCode(CodeType code_type, |
387 int code_index) { | 388 int code_index) { |
388 rtc::scoped_ptr<double[]> prob_weight(new double[kNumLossModels]); | 389 std::unique_ptr<double[]> prob_weight(new double[kNumLossModels]); |
389 memset(prob_weight.get() , 0, sizeof(double) * kNumLossModels); | 390 memset(prob_weight.get() , 0, sizeof(double) * kNumLossModels); |
390 MetricsFecCode metrics_code; | 391 MetricsFecCode metrics_code; |
391 SetMetricsZero(&metrics_code); | 392 SetMetricsZero(&metrics_code); |
392 | 393 |
393 int num_media_packets = code_params_[code_index].num_media_packets; | 394 int num_media_packets = code_params_[code_index].num_media_packets; |
394 int num_fec_packets = code_params_[code_index].num_fec_packets; | 395 int num_fec_packets = code_params_[code_index].num_fec_packets; |
395 int tot_num_packets = num_media_packets + num_fec_packets; | 396 int tot_num_packets = num_media_packets + num_fec_packets; |
396 rtc::scoped_ptr<uint8_t[]> state(new uint8_t[tot_num_packets]); | 397 std::unique_ptr<uint8_t[]> state(new uint8_t[tot_num_packets]); |
397 memset(state.get() , 0, tot_num_packets); | 398 memset(state.get() , 0, tot_num_packets); |
398 | 399 |
399 int num_loss_configurations = static_cast<int>(pow(2.0f, tot_num_packets)); | 400 int num_loss_configurations = static_cast<int>(pow(2.0f, tot_num_packets)); |
400 // Loop over all loss configurations for the symbol sequence of length | 401 // Loop over all loss configurations for the symbol sequence of length |
401 // |tot_num_packets|. In this version we process up to (k=12, m=12) codes, | 402 // |tot_num_packets|. In this version we process up to (k=12, m=12) codes, |
402 // and get exact expressions for the residual loss. | 403 // and get exact expressions for the residual loss. |
403 // TODO(marpan): For larger codes, loop over some random sample of loss | 404 // TODO(marpan): For larger codes, loop over some random sample of loss |
404 // configurations, sampling driven by the underlying statistical loss model | 405 // configurations, sampling driven by the underlying statistical loss model |
405 // (importance sampling). | 406 // (importance sampling). |
406 | 407 |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 recovery_rate_per_loss[loss_number], | 1073 recovery_rate_per_loss[loss_number], |
1073 kRecoveryRateXorRandom[2]); | 1074 kRecoveryRateXorRandom[2]); |
1074 EXPECT_GE(kMetricsXorBursty[code_index]. | 1075 EXPECT_GE(kMetricsXorBursty[code_index]. |
1075 recovery_rate_per_loss[loss_number], | 1076 recovery_rate_per_loss[loss_number], |
1076 kRecoveryRateXorBursty[2]); | 1077 kRecoveryRateXorBursty[2]); |
1077 } | 1078 } |
1078 } | 1079 } |
1079 } | 1080 } |
1080 | 1081 |
1081 } // namespace webrtc | 1082 } // namespace webrtc |
OLD | NEW |