Remove payload duplication in AudioDecoderTest
This hack was made to come around issue 845. Now that is solved, and
the test code can be cleaned up.
BUG=845
R=kwiberg@webrtc.org, tina.legrand@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/21709004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6534 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
index f82644cb..05684ac 100644
--- a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
@@ -54,6 +54,7 @@
// Create arrays.
ASSERT_GT(data_length_, 0u) << "The test must set data_length_ > 0";
input_ = new int16_t[data_length_];
+ // Longest encoded data is produced by PCM16b with 2 bytes per sample.
encoded_ = new uint8_t[data_length_ * 2];
decoded_ = new int16_t[data_length_ * channels_];
// Open input file.
@@ -172,24 +173,18 @@
// Encodes a payload and decodes it twice with decoder re-init before each
// decode. Verifies that the decoded result is the same.
void ReInitTest() {
- uint8_t* encoded = encoded_;
- uint8_t* encoded_copy = encoded_ + 2 * frame_size_;
int16_t* output1 = decoded_;
int16_t* output2 = decoded_ + frame_size_;
InitEncoder();
- size_t enc_len = EncodeFrame(input_, frame_size_, encoded);
+ size_t enc_len = EncodeFrame(input_, frame_size_, encoded_);
size_t dec_len;
- // Copy payload since iSAC fix destroys it during decode.
- // Issue: http://code.google.com/p/webrtc/issues/detail?id=845.
- // TODO(hlundin): Remove if the iSAC bug gets fixed.
- memcpy(encoded_copy, encoded, enc_len);
AudioDecoder::SpeechType speech_type1, speech_type2;
EXPECT_EQ(0, decoder_->Init());
- dec_len = decoder_->Decode(encoded, enc_len, output1, &speech_type1);
+ dec_len = decoder_->Decode(encoded_, enc_len, output1, &speech_type1);
EXPECT_EQ(frame_size_ * channels_, dec_len);
// Re-init decoder and decode again.
EXPECT_EQ(0, decoder_->Init());
- dec_len = decoder_->Decode(encoded_copy, enc_len, output2, &speech_type2);
+ dec_len = decoder_->Decode(encoded_, enc_len, output2, &speech_type2);
EXPECT_EQ(frame_size_ * channels_, dec_len);
for (unsigned int n = 0; n < frame_size_; ++n) {
ASSERT_EQ(output1[n], output2[n]) << "Exit test on first diff; n = " << n;