AudioEncoderCng: Handle case where speech encoder is reset

Previously, AudioEncoderCng required the speech encoder to not change
its mind regarding the number of 10 ms frames in the next packet
between calls to AudioEncoderCng::EncodeInternal()---specifically, it
could handle an upward but not a downward adjustment. With this patch,
it can handle a downward adjustment too, by simply saving the
overshoot data for the next call to EncodeInternal().

It will still not handle the case where the encoder's reported number
of 10 ms frames in the next packet is inconsistent with the behavior
of its Encode() function when called with no intervening changes to
the encoder.

R=henrik.lundin@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#9261}
This commit is contained in:
Henrik Lundin
2015-05-22 15:13:41 +02:00
parent f761d10393
commit 367c868c99
3 changed files with 55 additions and 54 deletions

View File

@ -66,16 +66,19 @@ class AudioEncoderCng final : public AudioEncoder {
inline void operator()(CNG_enc_inst* ptr) const { WebRtcCng_FreeEnc(ptr); }
};
EncodedInfo EncodePassive(size_t max_encoded_bytes, uint8_t* encoded);
EncodedInfo EncodeActive(size_t max_encoded_bytes, uint8_t* encoded);
EncodedInfo EncodePassive(int frames_to_encode,
size_t max_encoded_bytes,
uint8_t* encoded);
EncodedInfo EncodeActive(int frames_to_encode,
size_t max_encoded_bytes,
uint8_t* encoded);
size_t SamplesPer10msFrame() const;
AudioEncoder* speech_encoder_;
const int cng_payload_type_;
const int num_cng_coefficients_;
std::vector<int16_t> speech_buffer_;
uint32_t first_timestamp_in_buffer_;
int frames_in_buffer_;
std::vector<uint32_t> rtp_timestamps_;
bool last_frame_active_;
rtc::scoped_ptr<Vad> vad_;
rtc::scoped_ptr<CNG_enc_inst, CngInstDeleter> cng_inst_;