Prevent crash in NetEQ when decoder overflow.
NetEQ can crash when decoder gives too many output samples than it can handle. A practical case this happens is when multiple opus packets are combined. The best solution is to pass the max size to the ACM decode function and let it return a failure if the max size if too small. BUG=4361 R=henrik.lundin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/45619004 Cr-Commit-Position: refs/heads/master@{#8730} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8730 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -37,13 +37,15 @@ namespace webrtc {
|
||||
class AudioDecoderPcmU : public AudioDecoder {
|
||||
public:
|
||||
AudioDecoderPcmU() {}
|
||||
virtual int Decode(const uint8_t* encoded,
|
||||
virtual int Init() { return 0; }
|
||||
virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
|
||||
|
||||
protected:
|
||||
int DecodeInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type);
|
||||
virtual int Init() { return 0; }
|
||||
virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
|
||||
SpeechType* speech_type) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmU);
|
||||
@ -52,13 +54,15 @@ class AudioDecoderPcmU : public AudioDecoder {
|
||||
class AudioDecoderPcmA : public AudioDecoder {
|
||||
public:
|
||||
AudioDecoderPcmA() {}
|
||||
virtual int Decode(const uint8_t* encoded,
|
||||
virtual int Init() { return 0; }
|
||||
virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
|
||||
|
||||
protected:
|
||||
int DecodeInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type);
|
||||
virtual int Init() { return 0; }
|
||||
virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
|
||||
SpeechType* speech_type) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmA);
|
||||
@ -92,13 +96,15 @@ class AudioDecoderPcmAMultiCh : public AudioDecoderPcmA {
|
||||
class AudioDecoderPcm16B : public AudioDecoder {
|
||||
public:
|
||||
AudioDecoderPcm16B();
|
||||
virtual int Decode(const uint8_t* encoded,
|
||||
virtual int Init() { return 0; }
|
||||
virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
|
||||
|
||||
protected:
|
||||
int DecodeInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type);
|
||||
virtual int Init() { return 0; }
|
||||
virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
|
||||
SpeechType* speech_type) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcm16B);
|
||||
@ -121,15 +127,17 @@ class AudioDecoderIlbc : public AudioDecoder {
|
||||
public:
|
||||
AudioDecoderIlbc();
|
||||
virtual ~AudioDecoderIlbc();
|
||||
virtual int Decode(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type);
|
||||
virtual bool HasDecodePlc() const { return true; }
|
||||
virtual int DecodePlc(int num_frames, int16_t* decoded);
|
||||
virtual int Init();
|
||||
|
||||
protected:
|
||||
int DecodeInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type) override;
|
||||
|
||||
private:
|
||||
IlbcDecoderInstance* dec_state_;
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderIlbc);
|
||||
@ -141,15 +149,17 @@ class AudioDecoderG722 : public AudioDecoder {
|
||||
public:
|
||||
AudioDecoderG722();
|
||||
virtual ~AudioDecoderG722();
|
||||
virtual int Decode(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type);
|
||||
virtual bool HasDecodePlc() const { return false; }
|
||||
virtual int Init();
|
||||
virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
|
||||
|
||||
protected:
|
||||
int DecodeInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type) override;
|
||||
|
||||
private:
|
||||
G722DecInst* dec_state_;
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderG722);
|
||||
@ -159,12 +169,14 @@ class AudioDecoderG722Stereo : public AudioDecoder {
|
||||
public:
|
||||
AudioDecoderG722Stereo();
|
||||
virtual ~AudioDecoderG722Stereo();
|
||||
virtual int Decode(const uint8_t* encoded,
|
||||
virtual int Init();
|
||||
|
||||
protected:
|
||||
int DecodeInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type);
|
||||
virtual int Init();
|
||||
SpeechType* speech_type) override;
|
||||
|
||||
private:
|
||||
// Splits the stereo-interleaved payload in |encoded| into separate payloads
|
||||
@ -187,22 +199,25 @@ class AudioDecoderOpus : public AudioDecoder {
|
||||
public:
|
||||
explicit AudioDecoderOpus(int num_channels);
|
||||
virtual ~AudioDecoderOpus();
|
||||
virtual int Decode(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,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type);
|
||||
|
||||
virtual int Init();
|
||||
virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
|
||||
virtual int PacketDurationRedundant(const uint8_t* encoded,
|
||||
size_t encoded_len) const;
|
||||
virtual bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const;
|
||||
|
||||
protected:
|
||||
int DecodeInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type) override;
|
||||
int DecodeRedundantInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type) override;
|
||||
|
||||
private:
|
||||
OpusDecInst* dec_state_;
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderOpus);
|
||||
@ -219,13 +234,6 @@ class AudioDecoderCng : public AudioDecoder {
|
||||
public:
|
||||
explicit AudioDecoderCng();
|
||||
virtual ~AudioDecoderCng();
|
||||
virtual int Decode(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int /*sample_rate_hz*/,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type) {
|
||||
return -1;
|
||||
}
|
||||
virtual int Init();
|
||||
virtual int IncomingPacket(const uint8_t* payload,
|
||||
size_t payload_len,
|
||||
@ -235,6 +243,15 @@ class AudioDecoderCng : public AudioDecoder {
|
||||
|
||||
CNG_dec_inst* CngDecoderInstance() override { return dec_state_; }
|
||||
|
||||
protected:
|
||||
int DecodeInternal(const uint8_t* encoded,
|
||||
size_t encoded_len,
|
||||
int sample_rate_hz,
|
||||
int16_t* decoded,
|
||||
SpeechType* speech_type) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private:
|
||||
CNG_dec_inst* dec_state_;
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioDecoderCng);
|
||||
|
Reference in New Issue
Block a user