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

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc

Issue 1174813003: Prepare to convert various types to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Review comments + resync Created 5 years, 6 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 AudioCodecSpeedTest::TearDown(); 58 AudioCodecSpeedTest::TearDown();
59 // Free memory. 59 // Free memory.
60 EXPECT_EQ(0, WebRtcIsacfix_Free(ISACFIX_main_inst_)); 60 EXPECT_EQ(0, WebRtcIsacfix_Free(ISACFIX_main_inst_));
61 } 61 }
62 62
63 float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream, 63 float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
64 int max_bytes, int* encoded_bytes) { 64 int max_bytes, int* encoded_bytes) {
65 // ISAC takes 10 ms everycall 65 // ISAC takes 10 ms everycall
66 const int subblocks = block_duration_ms_ / 10; 66 const int subblocks = block_duration_ms_ / 10;
67 const int subblock_length = 10 * input_sampling_khz_; 67 const int subblock_length = 10 * input_sampling_khz_;
68 int value; 68 int value = 0;
69 69
70 clock_t clocks = clock(); 70 clock_t clocks = clock();
71 size_t pointer = 0; 71 size_t pointer = 0;
72 for (int idx = 0; idx < subblocks; idx++, pointer += subblock_length) { 72 for (int idx = 0; idx < subblocks; idx++, pointer += subblock_length) {
73 value = WebRtcIsacfix_Encode(ISACFIX_main_inst_, &in_data[pointer], 73 value = WebRtcIsacfix_Encode(ISACFIX_main_inst_, &in_data[pointer],
74 bit_stream); 74 bit_stream);
75 if (idx == subblocks - 1)
76 EXPECT_GT(value, 0);
77 else
78 EXPECT_EQ(0, value);
75 } 79 }
76 clocks = clock() - clocks; 80 clocks = clock() - clocks;
77 EXPECT_GT(value, 0);
78 assert(value <= max_bytes);
79 *encoded_bytes = value; 81 *encoded_bytes = value;
82 assert(*encoded_bytes <= max_bytes);
80 return 1000.0 * clocks / CLOCKS_PER_SEC; 83 return 1000.0 * clocks / CLOCKS_PER_SEC;
81 } 84 }
82 85
83 float IsacSpeedTest::DecodeABlock(const uint8_t* bit_stream, int encoded_bytes, 86 float IsacSpeedTest::DecodeABlock(const uint8_t* bit_stream, int encoded_bytes,
84 int16_t* out_data) { 87 int16_t* out_data) {
85 int value; 88 int value;
86 int16_t audio_type; 89 int16_t audio_type;
87 clock_t clocks = clock(); 90 clock_t clocks = clock();
88 value = WebRtcIsacfix_Decode(ISACFIX_main_inst_, 91 value = WebRtcIsacfix_Decode(ISACFIX_main_inst_,
89 bit_stream, 92 bit_stream,
90 encoded_bytes, out_data, &audio_type); 93 encoded_bytes, out_data, &audio_type);
91 clocks = clock() - clocks; 94 clocks = clock() - clocks;
92 EXPECT_EQ(output_length_sample_, value); 95 EXPECT_EQ(output_length_sample_, value);
93 return 1000.0 * clocks / CLOCKS_PER_SEC; 96 return 1000.0 * clocks / CLOCKS_PER_SEC;
94 } 97 }
95 98
96 TEST_P(IsacSpeedTest, IsacEncodeDecodeTest) { 99 TEST_P(IsacSpeedTest, IsacEncodeDecodeTest) {
97 size_t kDurationSec = 400; // Test audio length in second. 100 size_t kDurationSec = 400; // Test audio length in second.
98 EncodeDecode(kDurationSec); 101 EncodeDecode(kDurationSec);
99 } 102 }
100 103
101 const coding_param param_set[] = 104 const coding_param param_set[] =
102 {::std::tr1::make_tuple(1, 32000, string("audio_coding/speech_mono_16kHz"), 105 {::std::tr1::make_tuple(1, 32000, string("audio_coding/speech_mono_16kHz"),
103 string("pcm"), true)}; 106 string("pcm"), true)};
104 107
105 INSTANTIATE_TEST_CASE_P(AllTest, IsacSpeedTest, 108 INSTANTIATE_TEST_CASE_P(AllTest, IsacSpeedTest,
106 ::testing::ValuesIn(param_set)); 109 ::testing::ValuesIn(param_set));
107 110
108 } // namespace webrtc 111 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698