OLD | NEW |
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/tools/audio_codec_speed_test.h" | 11 #include "webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.h" |
12 | 12 |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "webrtc/base/format_macros.h" |
14 #include "webrtc/test/testsupport/fileutils.h" | 15 #include "webrtc/test/testsupport/fileutils.h" |
15 | 16 |
16 using ::std::tr1::get; | 17 using ::std::tr1::get; |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 | 20 |
20 AudioCodecSpeedTest::AudioCodecSpeedTest(int block_duration_ms, | 21 AudioCodecSpeedTest::AudioCodecSpeedTest(int block_duration_ms, |
21 int input_sampling_khz, | 22 int input_sampling_khz, |
22 int output_sampling_khz) | 23 int output_sampling_khz) |
23 : block_duration_ms_(block_duration_ms), | 24 : block_duration_ms_(block_duration_ms), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void AudioCodecSpeedTest::TearDown() { | 93 void AudioCodecSpeedTest::TearDown() { |
93 if (save_out_data_) { | 94 if (save_out_data_) { |
94 fclose(out_file_); | 95 fclose(out_file_); |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 void AudioCodecSpeedTest::EncodeDecode(size_t audio_duration_sec) { | 99 void AudioCodecSpeedTest::EncodeDecode(size_t audio_duration_sec) { |
99 size_t time_now_ms = 0; | 100 size_t time_now_ms = 0; |
100 float time_ms; | 101 float time_ms; |
101 | 102 |
102 printf("Coding %d kHz-sampled %d-channel audio at %d bps ...\n", | 103 printf("Coding %d kHz-sampled %" PRIuS "-channel audio at %d bps ...\n", |
103 input_sampling_khz_, channels_, bit_rate_); | 104 input_sampling_khz_, channels_, bit_rate_); |
104 | 105 |
105 while (time_now_ms < audio_duration_sec * 1000) { | 106 while (time_now_ms < audio_duration_sec * 1000) { |
106 // Encode & decode. | 107 // Encode & decode. |
107 time_ms = EncodeABlock(&in_data_[data_pointer_], &bit_stream_[0], | 108 time_ms = EncodeABlock(&in_data_[data_pointer_], &bit_stream_[0], |
108 max_bytes_, &encoded_bytes_); | 109 max_bytes_, &encoded_bytes_); |
109 encoding_time_ms_ += time_ms; | 110 encoding_time_ms_ += time_ms; |
110 time_ms = DecodeABlock(&bit_stream_[0], encoded_bytes_, &out_data_[0]); | 111 time_ms = DecodeABlock(&bit_stream_[0], encoded_bytes_, &out_data_[0]); |
111 decoding_time_ms_ += time_ms; | 112 decoding_time_ms_ += time_ms; |
112 if (save_out_data_) { | 113 if (save_out_data_) { |
113 fwrite(&out_data_[0], sizeof(int16_t), | 114 fwrite(&out_data_[0], sizeof(int16_t), |
114 output_length_sample_ * channels_, out_file_); | 115 output_length_sample_ * channels_, out_file_); |
115 } | 116 } |
116 data_pointer_ = (data_pointer_ + input_length_sample_ * channels_) % | 117 data_pointer_ = (data_pointer_ + input_length_sample_ * channels_) % |
117 loop_length_samples_; | 118 loop_length_samples_; |
118 time_now_ms += block_duration_ms_; | 119 time_now_ms += block_duration_ms_; |
119 } | 120 } |
120 | 121 |
121 printf("Encoding: %.2f%% real time,\nDecoding: %.2f%% real time.\n", | 122 printf("Encoding: %.2f%% real time,\nDecoding: %.2f%% real time.\n", |
122 (encoding_time_ms_ / audio_duration_sec) / 10.0, | 123 (encoding_time_ms_ / audio_duration_sec) / 10.0, |
123 (decoding_time_ms_ / audio_duration_sec) / 10.0); | 124 (decoding_time_ms_ / audio_duration_sec) / 10.0); |
124 } | 125 } |
125 | 126 |
126 } // namespace webrtc | 127 } // namespace webrtc |
OLD | NEW |