19a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org/*
29a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
39a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *
49a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  Use of this source code is governed by a BSD-style license
59a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  that can be found in the LICENSE file in the root of the source
69a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  tree. An additional intellectual property rights grant can be found
79a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  in the file PATENTS.  All contributing project authors may
89a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
99a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org */
109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
11e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
129a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include <assert.h>
149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include <stdlib.h>
159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include <string>
179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
1849d62206ededc5905d6121d42fdcce8ed665b2c0kjellander@webrtc.org#include "testing/gtest/include/gtest/gtest.h"
199a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/common_audio/resampler/include/resampler.h"
2024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#ifdef WEBRTC_CODEC_CELT
2124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#include "webrtc/modules/audio_coding/codecs/celt/include/celt_interface.h"
2224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#endif
239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
249a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h"
259a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h"
269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h"
279a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h"
289a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h"
299a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
309a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/system_wrappers/interface/data_log.h"
319a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include "webrtc/test/testsupport/fileutils.h"
329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgnamespace webrtc {
349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
359a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderTest : public ::testing::Test {
369a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderTest()
389a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    : input_fp_(NULL),
399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      input_(NULL),
409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      encoded_(NULL),
419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      decoded_(NULL),
429a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      frame_size_(0),
439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      data_length_(0),
449a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      encoded_bytes_(0),
45162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org      channels_(1),
469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      decoder_(NULL) {
479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input_file_ = webrtc::test::ProjectRootPath() +
489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org        "resources/audio_coding/testfile32kHz.pcm";
499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
519a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual ~AudioDecoderTest() {}
529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
539a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual void SetUp() {
549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Create arrays.
559a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_GT(data_length_, 0u) << "The test must set data_length_ > 0";
569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input_ = new int16_t[data_length_];
57f1a6eacbb485e8275cc81ad9d9170a75b65864eehenrik.lundin@webrtc.org    // Longest encoded data is produced by PCM16b with 2 bytes per sample.
589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    encoded_ = new uint8_t[data_length_ * 2];
59162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    decoded_ = new int16_t[data_length_ * channels_];
609a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Open input file.
619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input_fp_ = fopen(input_file_.c_str(), "rb");
629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_TRUE(input_fp_ != NULL) << "Failed to open file " << input_file_;
639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Read data to |input_|.
649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_EQ(data_length_,
659a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org              fread(input_, sizeof(int16_t), data_length_, input_fp_)) <<
669a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                  "Could not read enough data from file";
679a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Logging to view input and output in Matlab.
689a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Use 'gyp -Denable_data_logging=1' to enable logging.
699a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    DataLog::CreateLog();
709a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    DataLog::AddTable("CodecTest");
719a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    DataLog::AddColumn("CodecTest", "input", 1);
729a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    DataLog::AddColumn("CodecTest", "output", 1);
739a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
749a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
759a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual void TearDown() {
769a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    delete decoder_;
779a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = NULL;
789a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Close input file.
799a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    fclose(input_fp_);
809a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Delete arrays.
819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    delete [] input_;
829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input_ = NULL;
839a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    delete [] encoded_;
849a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    encoded_ = NULL;
859a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    delete [] decoded_;
869a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoded_ = NULL;
879a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Close log.
889a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    DataLog::ReturnLog();
899a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
909a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
919a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual void InitEncoder() { }
929a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
939a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  // This method must be implemented for all tests derived from this class.
949a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len,
959a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          uint8_t* output) = 0;
969a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
979a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  // Encodes and decodes audio. The absolute difference between the input and
989a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  // output is compared vs |tolerance|, and the mean-squared error is compared
99bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  // with |mse|. The encoded stream should contain |expected_bytes|. For stereo
100bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  // audio, the absolute difference between the two channels is compared vs
101bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  // |channel_diff_tolerance|.
1029a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  void EncodeDecodeTest(size_t expected_bytes, int tolerance, double mse,
103bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org                        int delay = 0, int channel_diff_tolerance = 0) {
1049a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_GE(tolerance, 0) << "Test must define a tolerance >= 0";
105bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    ASSERT_GE(channel_diff_tolerance, 0) <<
106bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org        "Test must define a channel_diff_tolerance >= 0";
1079a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    size_t processed_samples = 0u;
1089a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    encoded_bytes_ = 0u;
1099a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    InitEncoder();
1109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(0, decoder_->Init());
1119a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    while (processed_samples + frame_size_ <= data_length_) {
1129a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      size_t enc_len = EncodeFrame(&input_[processed_samples], frame_size_,
1139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                                   &encoded_[encoded_bytes_]);
1149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      AudioDecoder::SpeechType speech_type;
1159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      size_t dec_len = decoder_->Decode(&encoded_[encoded_bytes_], enc_len,
116162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org                                        &decoded_[processed_samples *
117162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org                                                  channels_],
1189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                                        &speech_type);
119162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org      EXPECT_EQ(frame_size_ * channels_, dec_len);
1209a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      encoded_bytes_ += enc_len;
1219a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      processed_samples += frame_size_;
1229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
123db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org    // For some codecs it doesn't make sense to check expected number of bytes,
124db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org    // since the number can vary for different platforms. Opus and iSAC are
125db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org    // such codecs. In this case expected_bytes is set to 0.
126db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org    if (expected_bytes) {
127db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org      EXPECT_EQ(expected_bytes, encoded_bytes_);
128db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org    }
1299a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    CompareInputOutput(processed_samples, tolerance, delay);
130bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    if (channels_ == 2)
131bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org      CompareTwoChannels(processed_samples, channel_diff_tolerance);
1329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_LE(MseInputOutput(processed_samples, delay), mse);
1339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
1349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
135162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  // The absolute difference between the input and output (the first channel) is
136162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  // compared vs |tolerance|. The parameter |delay| is used to correct for codec
137bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  // delays.
138162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  virtual void CompareInputOutput(size_t num_samples, int tolerance,
139162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org                                  int delay) const {
1409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(num_samples <= data_length_);
1419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    for (unsigned int n = 0; n < num_samples - delay; ++n) {
142162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org      ASSERT_NEAR(input_[n], decoded_[channels_ * n + delay], tolerance) <<
1439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org          "Exit test on first diff; n = " << n;
1449a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      DataLog::InsertCell("CodecTest", "input", input_[n]);
145162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org      DataLog::InsertCell("CodecTest", "output", decoded_[channels_ * n]);
1469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      DataLog::NextRow("CodecTest");
1479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
1499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
150bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  // The absolute difference between the two channels in a stereo is compared vs
151bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  // |tolerance|.
15224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  virtual void CompareTwoChannels(size_t samples_per_channel,
15324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org                                  int tolerance) const {
15424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    assert(samples_per_channel <= data_length_);
15524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    for (unsigned int n = 0; n < samples_per_channel; ++n)
15624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org      ASSERT_NEAR(decoded_[channels_ * n], decoded_[channels_ * n + 1],
15724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org                  tolerance) << "Stereo samples differ.";
158bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  }
159bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org
160162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  // Calculates mean-squared error between input and output (the first channel).
161162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  // The parameter |delay| is used to correct for codec delays.
162162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  virtual double MseInputOutput(size_t num_samples, int delay) const {
1639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(num_samples <= data_length_);
1649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    if (num_samples == 0) return 0.0;
1659a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    double squared_sum = 0.0;
1669a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    for (unsigned int n = 0; n < num_samples - delay; ++n) {
167162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org      squared_sum += (input_[n] - decoded_[channels_ * n + delay]) *
168162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org          (input_[n] - decoded_[channels_ * n + delay]);
1699a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1709a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return squared_sum / (num_samples - delay);
1719a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
1729a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
1739a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  // Encodes a payload and decodes it twice with decoder re-init before each
1749a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  // decode. Verifies that the decoded result is the same.
1759a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  void ReInitTest() {
1769a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    int16_t* output1 = decoded_;
1779a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    int16_t* output2 = decoded_ + frame_size_;
1789a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    InitEncoder();
179f1a6eacbb485e8275cc81ad9d9170a75b65864eehenrik.lundin@webrtc.org    size_t enc_len = EncodeFrame(input_, frame_size_, encoded_);
180bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    size_t dec_len;
1819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    AudioDecoder::SpeechType speech_type1, speech_type2;
1829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(0, decoder_->Init());
183f1a6eacbb485e8275cc81ad9d9170a75b65864eehenrik.lundin@webrtc.org    dec_len = decoder_->Decode(encoded_, enc_len, output1, &speech_type1);
184162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    EXPECT_EQ(frame_size_ * channels_, dec_len);
1859a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Re-init decoder and decode again.
1869a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(0, decoder_->Init());
187f1a6eacbb485e8275cc81ad9d9170a75b65864eehenrik.lundin@webrtc.org    dec_len = decoder_->Decode(encoded_, enc_len, output2, &speech_type2);
188162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    EXPECT_EQ(frame_size_ * channels_, dec_len);
1899a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    for (unsigned int n = 0; n < frame_size_; ++n) {
1909a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      ASSERT_EQ(output1[n], output2[n]) << "Exit test on first diff; n = " << n;
1919a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1929a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(speech_type1, speech_type2);
1939a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
1949a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
1959a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  // Call DecodePlc and verify that the correct number of samples is produced.
1969a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  void DecodePlcTest() {
1979a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    InitEncoder();
1989a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    size_t enc_len = EncodeFrame(input_, frame_size_, encoded_);
1999a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    AudioDecoder::SpeechType speech_type;
2009a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(0, decoder_->Init());
2019a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    size_t dec_len =
2029a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org        decoder_->Decode(encoded_, enc_len, decoded_, &speech_type);
20324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    EXPECT_EQ(frame_size_ * channels_, dec_len);
2049a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Call DecodePlc and verify that we get one frame of data.
2059a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // (Overwrite the output from the above Decode call, but that does not
2069a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // matter.)
2079a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    dec_len = decoder_->DecodePlc(1, decoded_);
20824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    EXPECT_EQ(frame_size_ * channels_, dec_len);
2099a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2119a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  std::string input_file_;
2129a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  FILE* input_fp_;
2139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int16_t* input_;
2149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  uint8_t* encoded_;
2159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int16_t* decoded_;
2169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  size_t frame_size_;
2179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  size_t data_length_;
2189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  size_t encoded_bytes_;
219162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  size_t channels_;
2209a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoder* decoder_;
2219a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
2229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderPcmUTest : public AudioDecoderTest {
2249a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
2259a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderPcmUTest() : AudioDecoderTest() {
2269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    frame_size_ = 160;
2279a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    data_length_ = 10 * frame_size_;
2289a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = new AudioDecoderPcmU;
2299a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(decoder_);
2309a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2319a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
2339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          uint8_t* output) {
2349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    int enc_len_bytes =
235045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org        WebRtcG711_EncodeU(NULL, const_cast<int16_t*>(input),
236045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org                           static_cast<int>(input_len_samples),
2379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                           reinterpret_cast<int16_t*>(output));
2389a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(input_len_samples, static_cast<size_t>(enc_len_bytes));
2399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return enc_len_bytes;
2409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
2429a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderPcmATest : public AudioDecoderTest {
2449a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
2459a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderPcmATest() : AudioDecoderTest() {
2469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    frame_size_ = 160;
2479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    data_length_ = 10 * frame_size_;
2489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = new AudioDecoderPcmA;
2499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(decoder_);
2509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2519a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
2539a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          uint8_t* output) {
2549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    int enc_len_bytes =
255045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org        WebRtcG711_EncodeA(NULL, const_cast<int16_t*>(input),
256045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org                           static_cast<int>(input_len_samples),
2579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                           reinterpret_cast<int16_t*>(output));
2589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(input_len_samples, static_cast<size_t>(enc_len_bytes));
2599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return enc_len_bytes;
2609a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
2629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderPcm16BTest : public AudioDecoderTest {
2649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
2659a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderPcm16BTest() : AudioDecoderTest() {
2669a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    frame_size_ = 160;
2679a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    data_length_ = 10 * frame_size_;
2689a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = new AudioDecoderPcm16B(kDecoderPCM16B);
2699a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(decoder_);
2709a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2719a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2729a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
2739a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          uint8_t* output) {
2749a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    int enc_len_bytes = WebRtcPcm16b_EncodeW16(
275045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org        const_cast<int16_t*>(input), static_cast<int>(input_len_samples),
2769a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org        reinterpret_cast<int16_t*>(output));
2779a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(2 * input_len_samples, static_cast<size_t>(enc_len_bytes));
2789a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return enc_len_bytes;
2799a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2809a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
2819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderIlbcTest : public AudioDecoderTest {
2839a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
2849a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderIlbcTest() : AudioDecoderTest() {
2859a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    frame_size_ = 240;
2869a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    data_length_ = 10 * frame_size_;
2879a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = new AudioDecoderIlbc;
2889a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(decoder_);
2899f4b55f8e10b9618d62524f95980f8e96b2a3160henrik.lundin@webrtc.org    WebRtcIlbcfix_EncoderCreate(&encoder_);
2909a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2919a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2929a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ~AudioDecoderIlbcTest() {
2939a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    WebRtcIlbcfix_EncoderFree(encoder_);
2949a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2959a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2969a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual void InitEncoder() {
2979a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, 30));  // 30 ms.
2989a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2999a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3009a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
3019a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          uint8_t* output) {
3029a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    int enc_len_bytes =
303045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org        WebRtcIlbcfix_Encode(encoder_, input,
304045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org                             static_cast<int>(input_len_samples),
3059a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                             reinterpret_cast<int16_t*>(output));
3069a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(50, enc_len_bytes);
3079a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return enc_len_bytes;
3089a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3099a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  // Overload the default test since iLBC's function WebRtcIlbcfix_NetEqPlc does
3119a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  // not return any data. It simply resets a few states and returns 0.
3129a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  void DecodePlcTest() {
3139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    InitEncoder();
3149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    size_t enc_len = EncodeFrame(input_, frame_size_, encoded_);
3159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    AudioDecoder::SpeechType speech_type;
3169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(0, decoder_->Init());
3179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    size_t dec_len =
3189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org        decoder_->Decode(encoded_, enc_len, decoded_, &speech_type);
3199a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(frame_size_, dec_len);
3209a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Simply call DecodePlc and verify that we get 0 as return value.
3219a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(0, decoder_->DecodePlc(1, decoded_));
3229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3249a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  iLBC_encinst_t* encoder_;
3259a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
3269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3279a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderIsacFloatTest : public AudioDecoderTest {
3289a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
3299a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderIsacFloatTest() : AudioDecoderTest() {
3309a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input_size_ = 160;
3319a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    frame_size_ = 480;
3329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    data_length_ = 10 * frame_size_;
3339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = new AudioDecoderIsac;
3349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(decoder_);
3359f4b55f8e10b9618d62524f95980f8e96b2a3160henrik.lundin@webrtc.org    WebRtcIsac_Create(&encoder_);
3369f4b55f8e10b9618d62524f95980f8e96b2a3160henrik.lundin@webrtc.org    WebRtcIsac_SetEncSampRate(encoder_, 16000);
3379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3389a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ~AudioDecoderIsacFloatTest() {
3409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    WebRtcIsac_Free(encoder_);
3419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3429a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual void InitEncoder() {
3449a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_EQ(0, WebRtcIsac_EncoderInit(encoder_, 1));  // Fixed mode.
3459a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_EQ(0, WebRtcIsac_Control(encoder_, 32000, 30));  // 32 kbps, 30 ms.
3469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
3499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          uint8_t* output) {
3509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Insert 3 * 10 ms. Expect non-zero output on third call.
35183a60f3561a5a6d75f0044cf3161424d511f4066kwiberg@webrtc.org    EXPECT_EQ(0, WebRtcIsac_Encode(encoder_, input, output));
3529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input += input_size_;
35383a60f3561a5a6d75f0044cf3161424d511f4066kwiberg@webrtc.org    EXPECT_EQ(0, WebRtcIsac_Encode(encoder_, input, output));
3549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input += input_size_;
35583a60f3561a5a6d75f0044cf3161424d511f4066kwiberg@webrtc.org    int enc_len_bytes = WebRtcIsac_Encode(encoder_, input, output);
3569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_GT(enc_len_bytes, 0);
3579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return enc_len_bytes;
3589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3609a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ISACStruct* encoder_;
3619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int input_size_;
3629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
3639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderIsacSwbTest : public AudioDecoderTest {
3659a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
3669a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderIsacSwbTest() : AudioDecoderTest() {
3679a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input_size_ = 320;
3689a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    frame_size_ = 960;
3699a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    data_length_ = 10 * frame_size_;
3709a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = new AudioDecoderIsacSwb;
3719a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(decoder_);
3729f4b55f8e10b9618d62524f95980f8e96b2a3160henrik.lundin@webrtc.org    WebRtcIsac_Create(&encoder_);
3739f4b55f8e10b9618d62524f95980f8e96b2a3160henrik.lundin@webrtc.org    WebRtcIsac_SetEncSampRate(encoder_, 32000);
3749a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3759a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3769a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ~AudioDecoderIsacSwbTest() {
3779a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    WebRtcIsac_Free(encoder_);
3789a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3799a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3809a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual void InitEncoder() {
3819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_EQ(0, WebRtcIsac_EncoderInit(encoder_, 1));  // Fixed mode.
3829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_EQ(0, WebRtcIsac_Control(encoder_, 32000, 30));  // 32 kbps, 30 ms.
3839a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3849a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3859a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
3869a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          uint8_t* output) {
3879a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Insert 3 * 10 ms. Expect non-zero output on third call.
38883a60f3561a5a6d75f0044cf3161424d511f4066kwiberg@webrtc.org    EXPECT_EQ(0, WebRtcIsac_Encode(encoder_, input, output));
3899a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input += input_size_;
39083a60f3561a5a6d75f0044cf3161424d511f4066kwiberg@webrtc.org    EXPECT_EQ(0, WebRtcIsac_Encode(encoder_, input, output));
3919a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input += input_size_;
39283a60f3561a5a6d75f0044cf3161424d511f4066kwiberg@webrtc.org    int enc_len_bytes = WebRtcIsac_Encode(encoder_, input, output);
3939a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_GT(enc_len_bytes, 0);
3949a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return enc_len_bytes;
3959a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
3969a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
3979a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ISACStruct* encoder_;
3989a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int input_size_;
3999a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
4009a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4014d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org// This test is identical to AudioDecoderIsacSwbTest, except that it creates
4024d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org// an AudioDecoderIsacFb decoder object.
4034d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.orgclass AudioDecoderIsacFbTest : public AudioDecoderIsacSwbTest {
4044d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org protected:
4054d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  AudioDecoderIsacFbTest() : AudioDecoderIsacSwbTest() {
4064d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org    // Delete the |decoder_| that was created by AudioDecoderIsacSwbTest and
4074d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org    // create an AudioDecoderIsacFb object instead.
4084d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org    delete decoder_;
4094d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org    decoder_ = new AudioDecoderIsacFb;
4104d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org    assert(decoder_);
4114d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  }
4124d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org};
4134d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org
4149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderIsacFixTest : public AudioDecoderTest {
4159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
4169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderIsacFixTest() : AudioDecoderTest() {
4179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input_size_ = 160;
4189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    frame_size_ = 480;
4199a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    data_length_ = 10 * frame_size_;
4209a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = new AudioDecoderIsacFix;
4219a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(decoder_);
4229f4b55f8e10b9618d62524f95980f8e96b2a3160henrik.lundin@webrtc.org    WebRtcIsacfix_Create(&encoder_);
4239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
4249a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4259a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ~AudioDecoderIsacFixTest() {
4269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    WebRtcIsacfix_Free(encoder_);
4279a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
4289a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4299a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual void InitEncoder() {
4309a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_EQ(0, WebRtcIsacfix_EncoderInit(encoder_, 1));  // Fixed mode.
4319a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_EQ(0,
4329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org              WebRtcIsacfix_Control(encoder_, 32000, 30));  // 32 kbps, 30 ms.
4339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
4349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4359a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
4369a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          uint8_t* output) {
4379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Insert 3 * 10 ms. Expect non-zero output on third call.
43883a60f3561a5a6d75f0044cf3161424d511f4066kwiberg@webrtc.org    EXPECT_EQ(0, WebRtcIsacfix_Encode(encoder_, input, output));
4399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input += input_size_;
44083a60f3561a5a6d75f0044cf3161424d511f4066kwiberg@webrtc.org    EXPECT_EQ(0, WebRtcIsacfix_Encode(encoder_, input, output));
4419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    input += input_size_;
44283a60f3561a5a6d75f0044cf3161424d511f4066kwiberg@webrtc.org    int enc_len_bytes = WebRtcIsacfix_Encode(encoder_, input, output);
4439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_GT(enc_len_bytes, 0);
4449a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return enc_len_bytes;
4459a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
4469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ISACFIX_MainStruct* encoder_;
4489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int input_size_;
4499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
4509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4519a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderG722Test : public AudioDecoderTest {
4529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
4539a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderG722Test() : AudioDecoderTest() {
4549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    frame_size_ = 160;
4559a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    data_length_ = 10 * frame_size_;
4569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = new AudioDecoderG722;
4579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(decoder_);
4589f4b55f8e10b9618d62524f95980f8e96b2a3160henrik.lundin@webrtc.org    WebRtcG722_CreateEncoder(&encoder_);
4599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
4609a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ~AudioDecoderG722Test() {
4629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    WebRtcG722_FreeEncoder(encoder_);
4639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
4649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4659a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual void InitEncoder() {
4669a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    ASSERT_EQ(0, WebRtcG722_EncoderInit(encoder_));
4679a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
4689a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4699a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
4709a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          uint8_t* output) {
4719a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    int enc_len_bytes =
4729a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org        WebRtcG722_Encode(encoder_, const_cast<int16_t*>(input),
473045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org                          static_cast<int>(input_len_samples),
4749a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org                          reinterpret_cast<int16_t*>(output));
4759a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_EQ(80, enc_len_bytes);
4769a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return enc_len_bytes;
4779a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
4789a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
4799a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  G722EncInst* encoder_;
4809a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
4819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
482162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.orgclass AudioDecoderG722StereoTest : public AudioDecoderG722Test {
483162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org protected:
484162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  AudioDecoderG722StereoTest() : AudioDecoderG722Test() {
485162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    channels_ = 2;
486162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // Delete the |decoder_| that was created by AudioDecoderG722Test and
487162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // create an AudioDecoderG722Stereo object instead.
488162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    delete decoder_;
489162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    decoder_ = new AudioDecoderG722Stereo;
490162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    assert(decoder_);
491162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  }
492162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org
493162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
494162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org                          uint8_t* output) {
495162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    uint8_t* temp_output = new uint8_t[data_length_ * 2];
496162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // Encode a mono payload using the base test class.
497162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    int mono_enc_len_bytes =
498162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org        AudioDecoderG722Test::EncodeFrame(input, input_len_samples,
499162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org                                          temp_output);
500162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // The bit-stream consists of 4-bit samples:
501162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // +--------+--------+--------+
502162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // | s0  s1 | s2  s3 | s4  s5 |
503162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // +--------+--------+--------+
504162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    //
505162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // Duplicate them to the |output| such that the stereo stream becomes:
506162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // +--------+--------+--------+
507162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // | s0  s0 | s1  s1 | s2  s2 |
508162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    // +--------+--------+--------+
509162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    EXPECT_LE(mono_enc_len_bytes * 2, static_cast<int>(data_length_ * 2));
510162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    uint8_t* output_ptr = output;
511162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    for (int i = 0; i < mono_enc_len_bytes; ++i) {
512162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org      *output_ptr = (temp_output[i] & 0xF0) + (temp_output[i] >> 4);
513162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org      ++output_ptr;
514162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org      *output_ptr = (temp_output[i] << 4) + (temp_output[i] & 0x0F);
515162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org      ++output_ptr;
516162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    }
517162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    delete [] temp_output;
518162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    return mono_enc_len_bytes * 2;
519162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  }
520162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org};
521162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org
52224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#ifdef WEBRTC_CODEC_CELT
52324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.orgclass AudioDecoderCeltTest : public AudioDecoderTest {
52424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org protected:
52524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  static const int kEncodingRateBitsPerSecond = 64000;
52624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  AudioDecoderCeltTest() : AudioDecoderTest(), encoder_(NULL) {
52724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    frame_size_ = 640;
52824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    data_length_ = 10 * frame_size_;
52924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    decoder_ = AudioDecoder::CreateAudioDecoder(kDecoderCELT_32);
53024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    assert(decoder_);
53124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    WebRtcCelt_CreateEnc(&encoder_, static_cast<int>(channels_));
53224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  }
53324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
53424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  ~AudioDecoderCeltTest() {
53524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    WebRtcCelt_FreeEnc(encoder_);
53624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  }
53724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
53824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  virtual void InitEncoder() {
53924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    assert(encoder_);
54024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    ASSERT_EQ(0, WebRtcCelt_EncoderInit(
54124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org        encoder_, static_cast<int>(channels_), kEncodingRateBitsPerSecond));
54224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  }
54324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
54424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
54524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org                          uint8_t* output) {
54624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    assert(encoder_);
54724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    return WebRtcCelt_Encode(encoder_, input, output);
54824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  }
54924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
55024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  CELT_encinst_t* encoder_;
55124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org};
55224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
55324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.orgclass AudioDecoderCeltStereoTest : public AudioDecoderTest {
55424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org protected:
55524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  static const int kEncodingRateBitsPerSecond = 64000;
55624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  AudioDecoderCeltStereoTest() : AudioDecoderTest(), encoder_(NULL) {
55724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    channels_ = 2;
55824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    frame_size_ = 640;
55924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    data_length_ = 10 * frame_size_;
56024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    decoder_ = AudioDecoder::CreateAudioDecoder(kDecoderCELT_32_2ch);
56124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    assert(decoder_);
56224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    stereo_input_ = new int16_t[frame_size_ * channels_];
56324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    WebRtcCelt_CreateEnc(&encoder_, static_cast<int>(channels_));
56424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  }
56524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
56624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  ~AudioDecoderCeltStereoTest() {
56724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    delete [] stereo_input_;
56824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    WebRtcCelt_FreeEnc(encoder_);
56924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  }
57024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
57124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  virtual void InitEncoder() {
57224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    assert(encoder_);
57324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    ASSERT_EQ(0, WebRtcCelt_EncoderInit(
57424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org        encoder_, static_cast<int>(channels_), kEncodingRateBitsPerSecond));
57524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  }
57624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
57724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
57824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org                          uint8_t* output) {
57924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    assert(encoder_);
58024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    assert(stereo_input_);
58124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    for (size_t n = 0; n < frame_size_; ++n) {
58224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org      stereo_input_[n * 2] = stereo_input_[n * 2 + 1] = input[n];
58324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    }
58424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    return WebRtcCelt_Encode(encoder_, stereo_input_, output);
58524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  }
58624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
58724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  int16_t* stereo_input_;
58824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  CELT_encinst_t* encoder_;
58924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org};
59024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
59124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#endif
59224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
5939a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgclass AudioDecoderOpusTest : public AudioDecoderTest {
5949a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org protected:
5959a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  AudioDecoderOpusTest() : AudioDecoderTest() {
596254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    frame_size_ = 480;
5979a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    data_length_ = 10 * frame_size_;
5989a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    decoder_ = new AudioDecoderOpus(kDecoderOpus);
5999a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    assert(decoder_);
6009f4b55f8e10b9618d62524f95980f8e96b2a3160henrik.lundin@webrtc.org    WebRtcOpus_EncoderCreate(&encoder_, 1);
6019a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
6029a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
6039a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ~AudioDecoderOpusTest() {
6049a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    WebRtcOpus_EncoderFree(encoder_);
6059a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
6069a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
607254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org  virtual void SetUp() OVERRIDE {
608254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    AudioDecoderTest::SetUp();
6099a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    // Upsample from 32 to 48 kHz.
610254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    // Because Opus is 48 kHz codec but the input file is 32 kHz, so the data
611254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    // read in |AudioDecoderTest::SetUp| has to be upsampled.
612254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    // |AudioDecoderTest::SetUp| has read |data_length_| samples, which is more
613254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    // than necessary after upsampling, so the end of audio that has been read
614254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    // is unused and the end of the buffer is overwritten by the resampled data.
6159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    Resampler rs;
6169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    rs.Reset(32000, 48000, kResamplerSynchronous);
617254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    const int before_resamp_len_samples = static_cast<int>(data_length_) * 2
618254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org        / 3;
619254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    int16_t* before_resamp_input = new int16_t[before_resamp_len_samples];
620254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    memcpy(before_resamp_input, input_,
621254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org           sizeof(int16_t) * before_resamp_len_samples);
6229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    int resamp_len_samples;
623254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    EXPECT_EQ(0, rs.Push(before_resamp_input, before_resamp_len_samples,
624254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org                         input_, static_cast<int>(data_length_),
625045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org                         resamp_len_samples));
626254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    EXPECT_EQ(static_cast<int>(data_length_), resamp_len_samples);
627254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    delete[] before_resamp_input;
628254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org  }
629254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org
630254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org  virtual void InitEncoder() {}
631254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org
632254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
633254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org                          uint8_t* output) OVERRIDE {
634254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    int enc_len_bytes = WebRtcOpus_Encode(encoder_, const_cast<int16_t*>(input),
635254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org        static_cast<int16_t>(input_len_samples),
636254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org        static_cast<int16_t>(data_length_), output);
6379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    EXPECT_GT(enc_len_bytes, 0);
6389a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return enc_len_bytes;
6399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
6409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
6419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  OpusEncInst* encoder_;
6429a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org};
6439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
644254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.orgclass AudioDecoderOpusStereoTest : public AudioDecoderOpusTest {
645bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org protected:
646254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org  AudioDecoderOpusStereoTest() : AudioDecoderOpusTest() {
647bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    channels_ = 2;
648254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    WebRtcOpus_EncoderFree(encoder_);
649254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    delete decoder_;
650bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    decoder_ = new AudioDecoderOpus(kDecoderOpus_2ch);
651bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    assert(decoder_);
652bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    WebRtcOpus_EncoderCreate(&encoder_, 2);
653bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  }
654bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org
655bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
656254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org                          uint8_t* output) OVERRIDE {
657bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    // Create stereo by duplicating each sample in |input|.
658045e45efeca8776975254550137ec65268aadb54turaj@webrtc.org    const int input_stereo_samples = static_cast<int>(input_len_samples) * 2;
659bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    int16_t* input_stereo = new int16_t[input_stereo_samples];
660bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    for (size_t i = 0; i < input_len_samples; i++)
661bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org      input_stereo[i * 2] = input_stereo[i * 2 + 1] = input[i];
662254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org
663254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    int enc_len_bytes = WebRtcOpus_Encode(
664254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org        encoder_, input_stereo, static_cast<int16_t>(input_len_samples),
665254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org        static_cast<int16_t>(data_length_), output);
666bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    EXPECT_GT(enc_len_bytes, 0);
667254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org    delete[] input_stereo;
668bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org    return enc_len_bytes;
669bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  }
670bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org};
671bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org
6729a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST_F(AudioDecoderPcmUTest, EncodeDecode) {
6739a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int tolerance = 251;
6749a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  double mse = 1734.0;
6759a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCMu));
6769a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EncodeDecodeTest(data_length_, tolerance, mse);
6779a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ReInitTest();
6789a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_FALSE(decoder_->HasDecodePlc());
6799a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
6809a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
6819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST_F(AudioDecoderPcmATest, EncodeDecode) {
6829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int tolerance = 308;
6839a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  double mse = 1931.0;
6849a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCMa));
6859a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EncodeDecodeTest(data_length_, tolerance, mse);
6869a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ReInitTest();
6879a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_FALSE(decoder_->HasDecodePlc());
6889a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
6899a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
6909a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST_F(AudioDecoderPcm16BTest, EncodeDecode) {
6919a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int tolerance = 0;
6929a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  double mse = 0.0;
6939a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16B));
6949a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16Bwb));
6959a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16Bswb32kHz));
6969a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16Bswb48kHz));
6979a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EncodeDecodeTest(2 * data_length_, tolerance, mse);
6989a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ReInitTest();
6999a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_FALSE(decoder_->HasDecodePlc());
7009a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
7019a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
7029a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST_F(AudioDecoderIlbcTest, EncodeDecode) {
7039a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int tolerance = 6808;
7049a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  double mse = 2.13e6;
7059a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int delay = 80;  // Delay from input to output.
7069a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderILBC));
7079a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EncodeDecodeTest(500, tolerance, mse, delay);
7089a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ReInitTest();
7099a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(decoder_->HasDecodePlc());
7109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  DecodePlcTest();
7119a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
7129a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
7139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST_F(AudioDecoderIsacFloatTest, EncodeDecode) {
7149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int tolerance = 3399;
7159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  double mse = 434951.0;
7169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int delay = 48;  // Delay from input to output.
7179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderISAC));
718db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org  EncodeDecodeTest(0, tolerance, mse, delay);
7199a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ReInitTest();
7209a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(decoder_->HasDecodePlc());
7219a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  DecodePlcTest();
7229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
7239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
7249a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST_F(AudioDecoderIsacSwbTest, EncodeDecode) {
7259a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int tolerance = 19757;
7269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  double mse = 8.18e6;
7279a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int delay = 160;  // Delay from input to output.
7289a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderISACswb));
729db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org  EncodeDecodeTest(0, tolerance, mse, delay);
7309a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ReInitTest();
7319a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(decoder_->HasDecodePlc());
7329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  DecodePlcTest();
7339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
7349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
7354d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.orgTEST_F(AudioDecoderIsacFbTest, EncodeDecode) {
7364d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  int tolerance = 19757;
7374d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  double mse = 8.18e6;
7384d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  int delay = 160;  // Delay from input to output.
7394d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderISACswb));
740db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org  EncodeDecodeTest(0, tolerance, mse, delay);
7414d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  ReInitTest();
7424d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  EXPECT_TRUE(decoder_->HasDecodePlc());
7434d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  DecodePlcTest();
7444d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org}
7454d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org
746b3cf4ca73920eee32b6818ef9e04872d5de66344henrik.lundin@webrtc.orgTEST_F(AudioDecoderIsacFixTest, DISABLED_EncodeDecode) {
7479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int tolerance = 11034;
7489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  double mse = 3.46e6;
7499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int delay = 54;  // Delay from input to output.
7509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderISAC));
7519a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EncodeDecodeTest(735, tolerance, mse, delay);
7529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ReInitTest();
7539a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_FALSE(decoder_->HasDecodePlc());
7549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
7559a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
7569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST_F(AudioDecoderG722Test, EncodeDecode) {
7579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int tolerance = 6176;
7589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  double mse = 238630.0;
7599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int delay = 22;  // Delay from input to output.
7609a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderG722));
7619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EncodeDecodeTest(data_length_ / 2, tolerance, mse, delay);
7629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ReInitTest();
7639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_FALSE(decoder_->HasDecodePlc());
7649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
7659a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
766162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.orgTEST_F(AudioDecoderG722StereoTest, CreateAndDestroy) {
767162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderG722_2ch));
768162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org}
769162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org
770162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.orgTEST_F(AudioDecoderG722StereoTest, EncodeDecode) {
771162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  int tolerance = 6176;
772bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  int channel_diff_tolerance = 0;
773162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  double mse = 238630.0;
774162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  int delay = 22;  // Delay from input to output.
775162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderG722_2ch));
776bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  EncodeDecodeTest(data_length_, tolerance, mse, delay, channel_diff_tolerance);
777162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  ReInitTest();
778162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  EXPECT_FALSE(decoder_->HasDecodePlc());
779162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org}
780162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org
7819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST_F(AudioDecoderOpusTest, EncodeDecode) {
7829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int tolerance = 6176;
7839a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  double mse = 238630.0;
7849a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  int delay = 22;  // Delay from input to output.
7859a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderOpus));
786db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org  EncodeDecodeTest(0, tolerance, mse, delay);
7879a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  ReInitTest();
7889a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_FALSE(decoder_->HasDecodePlc());
7899a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
7909a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
791bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.orgTEST_F(AudioDecoderOpusStereoTest, EncodeDecode) {
792bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  int tolerance = 6176;
793bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  int channel_diff_tolerance = 0;
794bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  double mse = 238630.0;
795bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  int delay = 22;  // Delay from input to output.
796bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderOpus_2ch));
797db085fa015842f58dd7d67f247868ddf73f8c95ftina.legrand@webrtc.org  EncodeDecodeTest(0, tolerance, mse, delay, channel_diff_tolerance);
798bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  ReInitTest();
799bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org  EXPECT_FALSE(decoder_->HasDecodePlc());
800bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org}
801bb6151d2f39f97f3e4d063acff7d65d4f6df542aminyue@webrtc.org
80224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#ifdef WEBRTC_CODEC_CELT
80324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org// In the two following CELT tests, the low amplitude of the test signal allow
80424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org// us to have such low error thresholds, i.e. |tolerance|, |mse|. Furthermore,
80524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org// in general, stereo signals with identical channels do not result in identical
80624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org// encoded channels.
80724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.orgTEST_F(AudioDecoderCeltTest, EncodeDecode) {
80824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  int tolerance = 20;
80924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  double mse = 17.0;
81024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  int delay = 80;  // Delay from input to output in samples.
81124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderCELT_32));
81224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EncodeDecodeTest(1600, tolerance, mse, delay);
81324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  ReInitTest();
81424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EXPECT_TRUE(decoder_->HasDecodePlc());
81524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  DecodePlcTest();
81624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org}
81724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
81824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.orgTEST_F(AudioDecoderCeltStereoTest, EncodeDecode) {
81924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  int tolerance = 20;
82024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  // If both channels are identical, CELT not necessarily decodes identical
82124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  // channels. However, for this input this is the case.
82224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  int channel_diff_tolerance = 0;
82324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  double mse = 20.0;
82424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  // Delay from input to output in samples, accounting for stereo.
82524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  int delay = 160;
82624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderCELT_32_2ch));
82724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EncodeDecodeTest(1600, tolerance, mse, delay, channel_diff_tolerance);
82824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  ReInitTest();
82924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EXPECT_TRUE(decoder_->HasDecodePlc());
83024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  DecodePlcTest();
83124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org}
83224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#endif
83324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org
8349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST(AudioDecoder, CodecSampleRateHz) {
8359a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(8000, AudioDecoder::CodecSampleRateHz(kDecoderPCMu));
8369a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(8000, AudioDecoder::CodecSampleRateHz(kDecoderPCMa));
8379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(8000, AudioDecoder::CodecSampleRateHz(kDecoderPCMu_2ch));
8389a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(8000, AudioDecoder::CodecSampleRateHz(kDecoderPCMa_2ch));
8399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(8000, AudioDecoder::CodecSampleRateHz(kDecoderILBC));
8409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(16000, AudioDecoder::CodecSampleRateHz(kDecoderISAC));
8419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(32000, AudioDecoder::CodecSampleRateHz(kDecoderISACswb));
8424d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  EXPECT_EQ(32000, AudioDecoder::CodecSampleRateHz(kDecoderISACfb));
8439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(8000, AudioDecoder::CodecSampleRateHz(kDecoderPCM16B));
8449a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(16000, AudioDecoder::CodecSampleRateHz(kDecoderPCM16Bwb));
8459a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(32000, AudioDecoder::CodecSampleRateHz(kDecoderPCM16Bswb32kHz));
8469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(48000, AudioDecoder::CodecSampleRateHz(kDecoderPCM16Bswb48kHz));
8479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(8000, AudioDecoder::CodecSampleRateHz(kDecoderPCM16B_2ch));
8489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(16000, AudioDecoder::CodecSampleRateHz(kDecoderPCM16Bwb_2ch));
8499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(32000, AudioDecoder::CodecSampleRateHz(kDecoderPCM16Bswb32kHz_2ch));
8509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(48000, AudioDecoder::CodecSampleRateHz(kDecoderPCM16Bswb48kHz_2ch));
8519a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(8000, AudioDecoder::CodecSampleRateHz(kDecoderPCM16B_5ch));
8529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(16000, AudioDecoder::CodecSampleRateHz(kDecoderG722));
853162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  EXPECT_EQ(16000, AudioDecoder::CodecSampleRateHz(kDecoderG722_2ch));
8549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(-1, AudioDecoder::CodecSampleRateHz(kDecoderRED));
8559a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(-1, AudioDecoder::CodecSampleRateHz(kDecoderAVT));
8569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(8000, AudioDecoder::CodecSampleRateHz(kDecoderCNGnb));
8579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(16000, AudioDecoder::CodecSampleRateHz(kDecoderCNGwb));
8589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(32000, AudioDecoder::CodecSampleRateHz(kDecoderCNGswb32kHz));
859254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org  EXPECT_EQ(48000, AudioDecoder::CodecSampleRateHz(kDecoderOpus));
860254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org  EXPECT_EQ(48000, AudioDecoder::CodecSampleRateHz(kDecoderOpus_2ch));
8619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  // TODO(tlegrand): Change 32000 to 48000 below once ACM has 48 kHz support.
8629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(32000, AudioDecoder::CodecSampleRateHz(kDecoderCNGswb48kHz));
8639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(-1, AudioDecoder::CodecSampleRateHz(kDecoderArbitrary));
86424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#ifdef WEBRTC_CODEC_CELT
86524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EXPECT_EQ(32000, AudioDecoder::CodecSampleRateHz(kDecoderCELT_32));
86624f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EXPECT_EQ(32000, AudioDecoder::CodecSampleRateHz(kDecoderCELT_32_2ch));
86724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#else
8689a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(-1, AudioDecoder::CodecSampleRateHz(kDecoderCELT_32));
8699a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_EQ(-1, AudioDecoder::CodecSampleRateHz(kDecoderCELT_32_2ch));
87024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#endif
8719a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
8729a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
8739a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgTEST(AudioDecoder, CodecSupported) {
8749a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCMu));
8759a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCMa));
8769a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCMu_2ch));
8779a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCMa_2ch));
8789a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderILBC));
8799a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderISAC));
8809a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderISACswb));
8814d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderISACfb));
8829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16B));
8839a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16Bwb));
8849a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16Bswb32kHz));
8859a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16Bswb48kHz));
8869a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16B_2ch));
8879a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16Bwb_2ch));
8889a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16Bswb32kHz_2ch));
8899a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16Bswb48kHz_2ch));
8909a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderPCM16B_5ch));
8919a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderG722));
892162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderG722_2ch));
8939a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderRED));
8949a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderAVT));
8959a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderCNGnb));
8969a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderCNGwb));
8979a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderCNGswb32kHz));
8989a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderCNGswb48kHz));
8999a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderArbitrary));
9009a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderOpus));
9019a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderOpus_2ch));
90224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#ifdef WEBRTC_CODEC_CELT
90324f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderCELT_32));
90424f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org  EXPECT_TRUE(AudioDecoder::CodecSupported(kDecoderCELT_32_2ch));
90524f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#else
9069a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_FALSE(AudioDecoder::CodecSupported(kDecoderCELT_32));
9079a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  EXPECT_FALSE(AudioDecoder::CodecSupported(kDecoderCELT_32_2ch));
90824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#endif
9099a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
9109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
9119a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}  // namespace webrtc
912