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

Side by Side Diff: webrtc/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc

Issue 1924443002: Revert of Replace the remaining scoped_ptr with unique_ptr in webrtc/modules/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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) 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
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
50 #include "testing/gtest/include/gtest/gtest.h" 48 #include "testing/gtest/include/gtest/gtest.h"
49 #include "webrtc/base/scoped_ptr.h"
51 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.h" 50 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.h"
52 #include "webrtc/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h " 51 #include "webrtc/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h "
53 #include "webrtc/test/testsupport/fileutils.h" 52 #include "webrtc/test/testsupport/fileutils.h"
54 53
55 namespace webrtc { 54 namespace webrtc {
56 55
57 // Maximum number of media packets allows for XOR (RFC 5109) code. 56 // Maximum number of media packets allows for XOR (RFC 5109) code.
58 enum { kMaxNumberMediaPackets = 48 }; 57 enum { kMaxNumberMediaPackets = 48 };
59 58
60 // Maximum number of media packets allowed for each mask type. 59 // Maximum number of media packets allowed for each mask type.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 184 }
186 return max_gap_loss; 185 return max_gap_loss;
187 } 186 }
188 187
189 // Returns the number of recovered media packets for the XOR code, given the 188 // Returns the number of recovered media packets for the XOR code, given the
190 // packet mask |fec_packet_masks_|, for the loss state/configuration given by 189 // packet mask |fec_packet_masks_|, for the loss state/configuration given by
191 // |state|. 190 // |state|.
192 int RecoveredMediaPackets(int num_media_packets, 191 int RecoveredMediaPackets(int num_media_packets,
193 int num_fec_packets, 192 int num_fec_packets,
194 uint8_t* state) { 193 uint8_t* state) {
195 std::unique_ptr<uint8_t[]> state_tmp( 194 rtc::scoped_ptr<uint8_t[]> state_tmp(
196 new uint8_t[num_media_packets + num_fec_packets]); 195 new uint8_t[num_media_packets + num_fec_packets]);
197 memcpy(state_tmp.get(), state, num_media_packets + num_fec_packets); 196 memcpy(state_tmp.get(), state, num_media_packets + num_fec_packets);
198 int num_recovered_packets = 0; 197 int num_recovered_packets = 0;
199 bool loop_again = true; 198 bool loop_again = true;
200 while (loop_again) { 199 while (loop_again) {
201 loop_again = false; 200 loop_again = false;
202 bool recovered_new_packet = false; 201 bool recovered_new_packet = false;
203 // Check if we can recover anything: loop over all possible FEC packets. 202 // Check if we can recover anything: loop over all possible FEC packets.
204 for (int i = 0; i < num_fec_packets; i++) { 203 for (int i = 0; i < num_fec_packets; i++) {
205 if (state_tmp[i + num_media_packets] == 0) { 204 if (state_tmp[i + num_media_packets] == 0) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 sizeof(double) * kNumStatesDistribution); 378 sizeof(double) * kNumStatesDistribution);
380 memset(metrics->recovery_rate_per_loss, 0, 379 memset(metrics->recovery_rate_per_loss, 0,
381 sizeof(double) * 2 * kMaxMediaPacketsTest + 1); 380 sizeof(double) * 2 * kMaxMediaPacketsTest + 1);
382 } 381 }
383 382
384 // Compute the metrics for an FEC code, given by the code type |code_type| 383 // Compute the metrics for an FEC code, given by the code type |code_type|
385 // (XOR-random/ bursty or RS), and by the code index |code_index| 384 // (XOR-random/ bursty or RS), and by the code index |code_index|
386 // (which containes the code size parameters/protection length). 385 // (which containes the code size parameters/protection length).
387 void ComputeMetricsForCode(CodeType code_type, 386 void ComputeMetricsForCode(CodeType code_type,
388 int code_index) { 387 int code_index) {
389 std::unique_ptr<double[]> prob_weight(new double[kNumLossModels]); 388 rtc::scoped_ptr<double[]> prob_weight(new double[kNumLossModels]);
390 memset(prob_weight.get() , 0, sizeof(double) * kNumLossModels); 389 memset(prob_weight.get() , 0, sizeof(double) * kNumLossModels);
391 MetricsFecCode metrics_code; 390 MetricsFecCode metrics_code;
392 SetMetricsZero(&metrics_code); 391 SetMetricsZero(&metrics_code);
393 392
394 int num_media_packets = code_params_[code_index].num_media_packets; 393 int num_media_packets = code_params_[code_index].num_media_packets;
395 int num_fec_packets = code_params_[code_index].num_fec_packets; 394 int num_fec_packets = code_params_[code_index].num_fec_packets;
396 int tot_num_packets = num_media_packets + num_fec_packets; 395 int tot_num_packets = num_media_packets + num_fec_packets;
397 std::unique_ptr<uint8_t[]> state(new uint8_t[tot_num_packets]); 396 rtc::scoped_ptr<uint8_t[]> state(new uint8_t[tot_num_packets]);
398 memset(state.get() , 0, tot_num_packets); 397 memset(state.get() , 0, tot_num_packets);
399 398
400 int num_loss_configurations = static_cast<int>(pow(2.0f, tot_num_packets)); 399 int num_loss_configurations = static_cast<int>(pow(2.0f, tot_num_packets));
401 // Loop over all loss configurations for the symbol sequence of length 400 // Loop over all loss configurations for the symbol sequence of length
402 // |tot_num_packets|. In this version we process up to (k=12, m=12) codes, 401 // |tot_num_packets|. In this version we process up to (k=12, m=12) codes,
403 // and get exact expressions for the residual loss. 402 // and get exact expressions for the residual loss.
404 // TODO(marpan): For larger codes, loop over some random sample of loss 403 // TODO(marpan): For larger codes, loop over some random sample of loss
405 // configurations, sampling driven by the underlying statistical loss model 404 // configurations, sampling driven by the underlying statistical loss model
406 // (importance sampling). 405 // (importance sampling).
407 406
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc ('k') | webrtc/modules/utility/include/jvm_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698