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

Side by Side Diff: webrtc/modules/audio_coding/codecs/opus/opus_speed_test.cc

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 3 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
11 #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h" 11 #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h"
12 #include "webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.h" 12 #include "webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.h"
13 13
14 using ::std::string; 14 using ::std::string;
15 15
16 namespace webrtc { 16 namespace webrtc {
17 17
18 static const int kOpusBlockDurationMs = 20; 18 static const int kOpusBlockDurationMs = 20;
19 static const int kOpusSamplingKhz = 48; 19 static const int kOpusSamplingKhz = 48;
20 20
21 class OpusSpeedTest : public AudioCodecSpeedTest { 21 class OpusSpeedTest : public AudioCodecSpeedTest {
22 protected: 22 protected:
23 OpusSpeedTest(); 23 OpusSpeedTest();
24 void SetUp() override; 24 void SetUp() override;
25 void TearDown() override; 25 void TearDown() override;
26 virtual float EncodeABlock(int16_t* in_data, uint8_t* bit_stream, 26 virtual float EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
27 int max_bytes, int* encoded_bytes); 27 size_t max_bytes, size_t* encoded_bytes);
28 virtual float DecodeABlock(const uint8_t* bit_stream, int encoded_bytes, 28 virtual float DecodeABlock(const uint8_t* bit_stream, size_t encoded_bytes,
29 int16_t* out_data); 29 int16_t* out_data);
30 WebRtcOpusEncInst* opus_encoder_; 30 WebRtcOpusEncInst* opus_encoder_;
31 WebRtcOpusDecInst* opus_decoder_; 31 WebRtcOpusDecInst* opus_decoder_;
32 }; 32 };
33 33
34 OpusSpeedTest::OpusSpeedTest() 34 OpusSpeedTest::OpusSpeedTest()
35 : AudioCodecSpeedTest(kOpusBlockDurationMs, 35 : AudioCodecSpeedTest(kOpusBlockDurationMs,
36 kOpusSamplingKhz, 36 kOpusSamplingKhz,
37 kOpusSamplingKhz), 37 kOpusSamplingKhz),
38 opus_encoder_(NULL), 38 opus_encoder_(NULL),
(...skipping 12 matching lines...) Expand all
51 } 51 }
52 52
53 void OpusSpeedTest::TearDown() { 53 void OpusSpeedTest::TearDown() {
54 AudioCodecSpeedTest::TearDown(); 54 AudioCodecSpeedTest::TearDown();
55 /* Free memory. */ 55 /* Free memory. */
56 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); 56 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_));
57 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); 57 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_));
58 } 58 }
59 59
60 float OpusSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream, 60 float OpusSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
61 int max_bytes, int* encoded_bytes) { 61 size_t max_bytes, size_t* encoded_bytes) {
62 clock_t clocks = clock(); 62 clock_t clocks = clock();
63 int value = WebRtcOpus_Encode(opus_encoder_, in_data, 63 int value = WebRtcOpus_Encode(opus_encoder_, in_data,
64 input_length_sample_, max_bytes, 64 input_length_sample_, max_bytes,
65 bit_stream); 65 bit_stream);
66 clocks = clock() - clocks; 66 clocks = clock() - clocks;
67 EXPECT_GT(value, 0); 67 EXPECT_GT(value, 0);
68 *encoded_bytes = value; 68 *encoded_bytes = static_cast<size_t>(value);
69 return 1000.0 * clocks / CLOCKS_PER_SEC; 69 return 1000.0 * clocks / CLOCKS_PER_SEC;
70 } 70 }
71 71
72 float OpusSpeedTest::DecodeABlock(const uint8_t* bit_stream, 72 float OpusSpeedTest::DecodeABlock(const uint8_t* bit_stream,
73 int encoded_bytes, int16_t* out_data) { 73 size_t encoded_bytes, int16_t* out_data) {
74 int value; 74 int value;
75 int16_t audio_type; 75 int16_t audio_type;
76 clock_t clocks = clock(); 76 clock_t clocks = clock();
77 value = WebRtcOpus_Decode(opus_decoder_, bit_stream, encoded_bytes, out_data, 77 value = WebRtcOpus_Decode(opus_decoder_, bit_stream, encoded_bytes, out_data,
78 &audio_type); 78 &audio_type);
79 clocks = clock() - clocks; 79 clocks = clock() - clocks;
80 EXPECT_EQ(output_length_sample_, value); 80 EXPECT_EQ(output_length_sample_, value);
81 return 1000.0 * clocks / CLOCKS_PER_SEC; 81 return 1000.0 * clocks / CLOCKS_PER_SEC;
82 } 82 }
83 83
(...skipping 28 matching lines...) Expand all
112 string("audio_coding/speech_mono_32_48kHz"), 112 string("audio_coding/speech_mono_32_48kHz"),
113 string("pcm"), true), 113 string("pcm"), true),
114 ::std::tr1::make_tuple(2, 64000, 114 ::std::tr1::make_tuple(2, 64000,
115 string("audio_coding/music_stereo_48kHz"), 115 string("audio_coding/music_stereo_48kHz"),
116 string("pcm"), true)}; 116 string("pcm"), true)};
117 117
118 INSTANTIATE_TEST_CASE_P(AllTest, OpusSpeedTest, 118 INSTANTIATE_TEST_CASE_P(AllTest, OpusSpeedTest,
119 ::testing::ValuesIn(param_set)); 119 ::testing::ValuesIn(param_set));
120 120
121 } // namespace webrtc 121 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/opus/opus_interface.c ('k') | webrtc/modules/audio_coding/codecs/opus/opus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698