Revert r8476 "Set decoder output frequency in AudioDecoder::Decode call"

This change uncovered issue 4143, evading the Memcheck suppression
since the signature is changed in the Decode function.

A fix for this is in the making; see
https://review.webrtc.org/36309004. This CL will be re-landed once the
fix is in place.

BUG=4143
TBR=kwiberg@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/42089004

Cr-Commit-Position: refs/heads/master@{#8488}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8488 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2015-02-24 21:17:50 +00:00
parent 348072845a
commit 903182bd8e
20 changed files with 184 additions and 201 deletions

View File

@ -18,10 +18,9 @@ namespace webrtc {
int AudioDecoder::DecodeRedundant(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
return Decode(encoded, encoded_len, sample_rate_hz, decoded, speech_type);
return Decode(encoded, encoded_len, decoded, speech_type);
}
bool AudioDecoder::HasDecodePlc() const { return false; }

View File

@ -37,22 +37,14 @@ class AudioDecoder {
// Decodes |encode_len| bytes from |encoded| and writes the result in
// |decoded|. The number of samples from all channels produced is in
// the return value. If the decoder produced comfort noise, |speech_type|
// is set to kComfortNoise, otherwise it is kSpeech. The desired output
// sample rate is provided in |sample_rate_hz|, which must be valid for the
// codec at hand.
virtual int Decode(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) = 0;
// is set to kComfortNoise, otherwise it is kSpeech.
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type) = 0;
// Same as Decode(), but interfaces to the decoders redundant decode function.
// The default implementation simply calls the regular Decode() method.
virtual int DecodeRedundant(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type);
virtual int DecodeRedundant(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type);
// Indicates if the decoder implements the DecodePlc method.
virtual bool HasDecodePlc() const;

View File

@ -66,6 +66,8 @@ class AudioEncoderDecoderIsacT : public AudioEncoder, public AudioDecoder {
explicit AudioEncoderDecoderIsacT(const ConfigAdaptive& config);
virtual ~AudioEncoderDecoderIsacT() OVERRIDE;
void UpdateDecoderSampleRate(int sample_rate_hz);
// AudioEncoder public methods.
virtual int SampleRateHz() const OVERRIDE;
virtual int NumChannels() const OVERRIDE;
@ -75,12 +77,10 @@ class AudioEncoderDecoderIsacT : public AudioEncoder, public AudioDecoder {
// AudioDecoder methods.
virtual int Decode(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) OVERRIDE;
virtual int DecodeRedundant(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) OVERRIDE;
virtual bool HasDecodePlc() const OVERRIDE;
@ -116,8 +116,6 @@ class AudioEncoderDecoderIsacT : public AudioEncoder, public AudioDecoder {
typename T::instance_type* isac_state_
GUARDED_BY(state_lock_) /* PT_GUARDED_BY(lock_)*/;
int decoder_sample_rate_hz_ GUARDED_BY(state_lock_);
// Must be acquired before state_lock_.
const scoped_ptr<CriticalSectionWrapper> lock_;

View File

@ -109,7 +109,6 @@ AudioEncoderDecoderIsacT<T>::AudioEncoderDecoderIsacT(const Config& config)
: payload_type_(config.payload_type),
red_payload_type_(config.red_payload_type),
state_lock_(CriticalSectionWrapper::CreateCriticalSection()),
decoder_sample_rate_hz_(0),
lock_(CriticalSectionWrapper::CreateCriticalSection()),
packet_in_progress_(false),
redundant_length_bytes_(0) {
@ -137,7 +136,6 @@ AudioEncoderDecoderIsacT<T>::AudioEncoderDecoderIsacT(
: payload_type_(config.payload_type),
red_payload_type_(config.red_payload_type),
state_lock_(CriticalSectionWrapper::CreateCriticalSection()),
decoder_sample_rate_hz_(0),
lock_(CriticalSectionWrapper::CreateCriticalSection()),
packet_in_progress_(false),
redundant_length_bytes_(0) {
@ -161,6 +159,12 @@ AudioEncoderDecoderIsacT<T>::~AudioEncoderDecoderIsacT() {
CHECK_EQ(0, T::Free(isac_state_));
}
template <typename T>
void AudioEncoderDecoderIsacT<T>::UpdateDecoderSampleRate(int sample_rate_hz) {
CriticalSectionScoped cs(state_lock_.get());
CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz));
}
template <typename T>
int AudioEncoderDecoderIsacT<T>::SampleRateHz() const {
CriticalSectionScoped cs(state_lock_.get());
@ -266,16 +270,9 @@ bool AudioEncoderDecoderIsacT<T>::EncodeInternal(uint32_t rtp_timestamp,
template <typename T>
int AudioEncoderDecoderIsacT<T>::Decode(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
CriticalSectionScoped cs(state_lock_.get());
CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000)
<< "Unsupported sample rate " << sample_rate_hz;
if (sample_rate_hz != decoder_sample_rate_hz_) {
CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz));
decoder_sample_rate_hz_ = sample_rate_hz;
}
int16_t temp_type = 1; // Default is speech.
int16_t ret =
T::Decode(isac_state_, encoded, static_cast<int16_t>(encoded_len),
@ -287,7 +284,6 @@ int AudioEncoderDecoderIsacT<T>::Decode(const uint8_t* encoded,
template <typename T>
int AudioEncoderDecoderIsacT<T>::DecodeRedundant(const uint8_t* encoded,
size_t encoded_len,
int /*sample_rate_hz*/,
int16_t* decoded,
SpeechType* speech_type) {
CriticalSectionScoped cs(state_lock_.get());