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

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

Issue 1172163004: Reformat existing code. There should be no functional effects. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include <string> 10 #include <string>
(...skipping 28 matching lines...) Expand all
39 void TestDtxEffect(bool dtx); 39 void TestDtxEffect(bool dtx);
40 40
41 // Prepare |speech_data_| for encoding, read from a hard-coded file. 41 // Prepare |speech_data_| for encoding, read from a hard-coded file.
42 // After preparation, |speech_data_.GetNextBlock()| returns a pointer to a 42 // After preparation, |speech_data_.GetNextBlock()| returns a pointer to a
43 // block of |block_length_ms| milliseconds. The data is looped every 43 // block of |block_length_ms| milliseconds. The data is looped every
44 // |loop_length_ms| milliseconds. 44 // |loop_length_ms| milliseconds.
45 void PrepareSpeechData(int channel, int block_length_ms, int loop_length_ms); 45 void PrepareSpeechData(int channel, int block_length_ms, int loop_length_ms);
46 46
47 int EncodeDecode(WebRtcOpusEncInst* encoder, 47 int EncodeDecode(WebRtcOpusEncInst* encoder,
48 const int16_t* input_audio, 48 const int16_t* input_audio,
49 const int input_samples, 49 int input_samples,
50 WebRtcOpusDecInst* decoder, 50 WebRtcOpusDecInst* decoder,
51 int16_t* output_audio, 51 int16_t* output_audio,
52 int16_t* audio_type); 52 int16_t* audio_type);
53 53
54 void SetMaxPlaybackRate(WebRtcOpusEncInst* encoder, 54 void SetMaxPlaybackRate(WebRtcOpusEncInst* encoder,
55 opus_int32 expect, int32_t set); 55 opus_int32 expect, int32_t set);
56 56
57 WebRtcOpusEncInst* opus_encoder_; 57 WebRtcOpusEncInst* opus_encoder_;
58 WebRtcOpusDecInst* opus_decoder_; 58 WebRtcOpusDecInst* opus_decoder_;
59 59
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 int32_t set) { 91 int32_t set) {
92 opus_int32 bandwidth; 92 opus_int32 bandwidth;
93 EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, set)); 93 EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, set));
94 opus_encoder_ctl(opus_encoder_->encoder, 94 opus_encoder_ctl(opus_encoder_->encoder,
95 OPUS_GET_MAX_BANDWIDTH(&bandwidth)); 95 OPUS_GET_MAX_BANDWIDTH(&bandwidth));
96 EXPECT_EQ(expect, bandwidth); 96 EXPECT_EQ(expect, bandwidth);
97 } 97 }
98 98
99 int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder, 99 int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder,
100 const int16_t* input_audio, 100 const int16_t* input_audio,
101 const int input_samples, 101 int input_samples,
102 WebRtcOpusDecInst* decoder, 102 WebRtcOpusDecInst* decoder,
103 int16_t* output_audio, 103 int16_t* output_audio,
104 int16_t* audio_type) { 104 int16_t* audio_type) {
105 encoded_bytes_ = WebRtcOpus_Encode(encoder, 105 encoded_bytes_ = WebRtcOpus_Encode(encoder,
106 input_audio, 106 input_audio,
107 input_samples, kMaxBytes, 107 input_samples, kMaxBytes,
108 bitstream_); 108 bitstream_);
109 EXPECT_GE(encoded_bytes_, 0); 109 EXPECT_GE(encoded_bytes_, 0);
110 return WebRtcOpus_Decode(decoder, bitstream_, 110 return WebRtcOpus_Decode(decoder, bitstream_,
111 encoded_bytes_, output_audio, 111 encoded_bytes_, output_audio,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 for (int i = 0; i < 30; ++i) { 158 for (int i = 0; i < 30; ++i) {
159 EXPECT_EQ(kOpus20msFrameSamples, 159 EXPECT_EQ(kOpus20msFrameSamples,
160 EncodeDecode(opus_encoder_, silence, 160 EncodeDecode(opus_encoder_, silence,
161 kOpus20msFrameSamples, opus_decoder_, 161 kOpus20msFrameSamples, opus_decoder_,
162 output_data_decode, &audio_type)); 162 output_data_decode, &audio_type));
163 if (!dtx) { 163 if (!dtx) {
164 EXPECT_GT(encoded_bytes_, 1); 164 EXPECT_GT(encoded_bytes_, 1);
165 EXPECT_EQ(0, opus_encoder_->in_dtx_mode); 165 EXPECT_EQ(0, opus_encoder_->in_dtx_mode);
166 EXPECT_EQ(0, opus_decoder_->in_dtx_mode); 166 EXPECT_EQ(0, opus_decoder_->in_dtx_mode);
167 EXPECT_EQ(0, audio_type); // Speech. 167 EXPECT_EQ(0, audio_type); // Speech.
168 } else if (1 == encoded_bytes_) { 168 } else if (encoded_bytes_ == 1) {
169 EXPECT_EQ(1, opus_encoder_->in_dtx_mode); 169 EXPECT_EQ(1, opus_encoder_->in_dtx_mode);
170 EXPECT_EQ(1, opus_decoder_->in_dtx_mode); 170 EXPECT_EQ(1, opus_decoder_->in_dtx_mode);
171 EXPECT_EQ(2, audio_type); // Comfort noise. 171 EXPECT_EQ(2, audio_type); // Comfort noise.
172 break; 172 break;
173 } 173 }
174 } 174 }
175 175
176 // When Opus is in DTX, it wakes up in a regular basis. It sends two packets, 176 // When Opus is in DTX, it wakes up in a regular basis. It sends two packets,
177 // one with an arbitrary size and the other of 1-byte, then stops sending for 177 // one with an arbitrary size and the other of 1-byte, then stops sending for
178 // 19 frames. 178 // 19 frames.
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_)); 607 EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_));
608 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_)); 608 EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_));
609 } 609 }
610 610
611 INSTANTIATE_TEST_CASE_P(VariousMode, 611 INSTANTIATE_TEST_CASE_P(VariousMode,
612 OpusTest, 612 OpusTest,
613 Combine(Values(1, 2), Values(0, 1))); 613 Combine(Values(1, 2), Values(0, 1)));
614 614
615 615
616 } // namespace webrtc 616 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698