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

Side by Side Diff: webrtc/modules/audio_coding/neteq/audio_decoder_unittest.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) 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // implementations are gone. 134 // implementations are gone.
135 virtual int EncodeFrame(const int16_t* input, 135 virtual int EncodeFrame(const int16_t* input,
136 size_t input_len_samples, 136 size_t input_len_samples,
137 uint8_t* output) { 137 uint8_t* output) {
138 encoded_info_.encoded_bytes = 0; 138 encoded_info_.encoded_bytes = 0;
139 const size_t samples_per_10ms = audio_encoder_->SampleRateHz() / 100; 139 const size_t samples_per_10ms = audio_encoder_->SampleRateHz() / 100;
140 CHECK_EQ(samples_per_10ms * audio_encoder_->Num10MsFramesInNextPacket(), 140 CHECK_EQ(samples_per_10ms * audio_encoder_->Num10MsFramesInNextPacket(),
141 input_len_samples); 141 input_len_samples);
142 rtc::scoped_ptr<int16_t[]> interleaved_input( 142 rtc::scoped_ptr<int16_t[]> interleaved_input(
143 new int16_t[channels_ * samples_per_10ms]); 143 new int16_t[channels_ * samples_per_10ms]);
144 for (int i = 0; i < audio_encoder_->Num10MsFramesInNextPacket(); ++i) { 144 for (size_t i = 0; i < audio_encoder_->Num10MsFramesInNextPacket(); ++i) {
145 EXPECT_EQ(0u, encoded_info_.encoded_bytes); 145 EXPECT_EQ(0u, encoded_info_.encoded_bytes);
146 146
147 // Duplicate the mono input signal to however many channels the test 147 // Duplicate the mono input signal to however many channels the test
148 // wants. 148 // wants.
149 test::InputAudioFile::DuplicateInterleaved(input + i * samples_per_10ms, 149 test::InputAudioFile::DuplicateInterleaved(input + i * samples_per_10ms,
150 samples_per_10ms, channels_, 150 samples_per_10ms, channels_,
151 interleaved_input.get()); 151 interleaved_input.get());
152 152
153 encoded_info_ = audio_encoder_->Encode( 153 encoded_info_ = audio_encoder_->Encode(
154 0, interleaved_input.get(), audio_encoder_->SampleRateHz() / 100, 154 0, interleaved_input.get(), audio_encoder_->SampleRateHz() / 100,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 input_audio_.Read(frame_size_, codec_input_rate_hz_, input.get())); 341 input_audio_.Read(frame_size_, codec_input_rate_hz_, input.get()));
342 size_t enc_len = EncodeFrame(input.get(), frame_size_, encoded_); 342 size_t enc_len = EncodeFrame(input.get(), frame_size_, encoded_);
343 AudioDecoder::SpeechType speech_type; 343 AudioDecoder::SpeechType speech_type;
344 EXPECT_EQ(0, decoder_->Init()); 344 EXPECT_EQ(0, decoder_->Init());
345 rtc::scoped_ptr<int16_t[]> output(new int16_t[frame_size_ * channels_]); 345 rtc::scoped_ptr<int16_t[]> output(new int16_t[frame_size_ * channels_]);
346 size_t dec_len = decoder_->Decode(encoded_, enc_len, codec_input_rate_hz_, 346 size_t dec_len = decoder_->Decode(encoded_, enc_len, codec_input_rate_hz_,
347 frame_size_ * channels_ * sizeof(int16_t), 347 frame_size_ * channels_ * sizeof(int16_t),
348 output.get(), &speech_type); 348 output.get(), &speech_type);
349 EXPECT_EQ(frame_size_, dec_len); 349 EXPECT_EQ(frame_size_, dec_len);
350 // Simply call DecodePlc and verify that we get 0 as return value. 350 // Simply call DecodePlc and verify that we get 0 as return value.
351 EXPECT_EQ(0, decoder_->DecodePlc(1, output.get())); 351 EXPECT_EQ(0U, decoder_->DecodePlc(1, output.get()));
352 } 352 }
353 }; 353 };
354 354
355 class AudioDecoderIsacFloatTest : public AudioDecoderTest { 355 class AudioDecoderIsacFloatTest : public AudioDecoderTest {
356 protected: 356 protected:
357 AudioDecoderIsacFloatTest() : AudioDecoderTest() { 357 AudioDecoderIsacFloatTest() : AudioDecoderTest() {
358 codec_input_rate_hz_ = 16000; 358 codec_input_rate_hz_ = 16000;
359 frame_size_ = 480; 359 frame_size_ = 480;
360 data_length_ = 10 * frame_size_; 360 data_length_ = 10 * frame_size_;
361 AudioEncoderIsac::Config config; 361 AudioEncoderIsac::Config config;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 EXPECT_TRUE(CodecSupported(kDecoderCNGnb)); 720 EXPECT_TRUE(CodecSupported(kDecoderCNGnb));
721 EXPECT_TRUE(CodecSupported(kDecoderCNGwb)); 721 EXPECT_TRUE(CodecSupported(kDecoderCNGwb));
722 EXPECT_TRUE(CodecSupported(kDecoderCNGswb32kHz)); 722 EXPECT_TRUE(CodecSupported(kDecoderCNGswb32kHz));
723 EXPECT_TRUE(CodecSupported(kDecoderCNGswb48kHz)); 723 EXPECT_TRUE(CodecSupported(kDecoderCNGswb48kHz));
724 EXPECT_TRUE(CodecSupported(kDecoderArbitrary)); 724 EXPECT_TRUE(CodecSupported(kDecoderArbitrary));
725 EXPECT_TRUE(CodecSupported(kDecoderOpus)); 725 EXPECT_TRUE(CodecSupported(kDecoderOpus));
726 EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch)); 726 EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch));
727 } 727 }
728 728
729 } // namespace webrtc 729 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc ('k') | webrtc/modules/audio_coding/neteq/background_noise.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698