Remove workaround for Opus DTX noise pumping issue.
A workaround for Opus DTX noise pumping issue was made according upon this https://codereview.webrtc.org/1422213003 Recently, Opus has fixed this problem internally, and hence the workaround is not needed any longer. This CL removes this workaround. BUG=586175 R=flim@webrtc.org, tina.legrand@webrtc.org Review URL: https://codereview.webrtc.org/1715423002 . Cr-Commit-Position: refs/heads/master@{#11805}
This commit is contained in:
@ -19,12 +19,6 @@ struct WebRtcOpusEncInst {
|
||||
OpusEncoder* encoder;
|
||||
size_t channels;
|
||||
int in_dtx_mode;
|
||||
// When Opus is in DTX mode, we use |zero_counts| to count consecutive zeros
|
||||
// to break long zero segment so as to prevent DTX from going wrong. We use
|
||||
// one counter for each channel. After each encoding, |zero_counts| contain
|
||||
// the remaining zeros from the last frame.
|
||||
// TODO(minyue): remove this when Opus gets an internal fix to DTX.
|
||||
size_t* zero_counts;
|
||||
};
|
||||
|
||||
struct WebRtcOpusDecInst {
|
||||
|
||||
@ -30,15 +30,6 @@ enum {
|
||||
|
||||
/* Default frame size, 20 ms @ 48 kHz, in samples (for one channel). */
|
||||
kWebRtcOpusDefaultFrameSize = 960,
|
||||
|
||||
// Maximum number of consecutive zeros, beyond or equal to which DTX can fail.
|
||||
kZeroBreakCount = 157,
|
||||
|
||||
#if defined(OPUS_FIXED_POINT)
|
||||
kZeroBreakValue = 10,
|
||||
#else
|
||||
kZeroBreakValue = 1,
|
||||
#endif
|
||||
};
|
||||
|
||||
int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst,
|
||||
@ -62,10 +53,6 @@ int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst,
|
||||
OpusEncInst* state = calloc(1, sizeof(OpusEncInst));
|
||||
assert(state);
|
||||
|
||||
// Allocate zero counters.
|
||||
state->zero_counts = calloc(channels, sizeof(size_t));
|
||||
assert(state->zero_counts);
|
||||
|
||||
int error;
|
||||
state->encoder = opus_encoder_create(48000, (int)channels, opus_app,
|
||||
&error);
|
||||
@ -84,7 +71,6 @@ int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst,
|
||||
int16_t WebRtcOpus_EncoderFree(OpusEncInst* inst) {
|
||||
if (inst) {
|
||||
opus_encoder_destroy(inst->encoder);
|
||||
free(inst->zero_counts);
|
||||
free(inst);
|
||||
return 0;
|
||||
} else {
|
||||
@ -98,42 +84,13 @@ int WebRtcOpus_Encode(OpusEncInst* inst,
|
||||
size_t length_encoded_buffer,
|
||||
uint8_t* encoded) {
|
||||
int res;
|
||||
size_t i;
|
||||
size_t c;
|
||||
|
||||
int16_t buffer[2 * 48 * kWebRtcOpusMaxEncodeFrameSizeMs];
|
||||
|
||||
if (samples > 48 * kWebRtcOpusMaxEncodeFrameSizeMs) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const size_t channels = inst->channels;
|
||||
int use_buffer = 0;
|
||||
|
||||
// Break long consecutive zeros by forcing a "1" every |kZeroBreakCount|
|
||||
// samples.
|
||||
if (inst->in_dtx_mode) {
|
||||
for (i = 0; i < samples; ++i) {
|
||||
for (c = 0; c < channels; ++c) {
|
||||
if (audio_in[i * channels + c] == 0) {
|
||||
++inst->zero_counts[c];
|
||||
if (inst->zero_counts[c] == kZeroBreakCount) {
|
||||
if (!use_buffer) {
|
||||
memcpy(buffer, audio_in, samples * channels * sizeof(int16_t));
|
||||
use_buffer = 1;
|
||||
}
|
||||
buffer[i * channels + c] = kZeroBreakValue;
|
||||
inst->zero_counts[c] = 0;
|
||||
}
|
||||
} else {
|
||||
inst->zero_counts[c] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res = opus_encode(inst->encoder,
|
||||
use_buffer ? buffer : audio_in,
|
||||
(const opus_int16*)audio_in,
|
||||
(int)samples,
|
||||
encoded,
|
||||
(opus_int32)length_encoded_buffer);
|
||||
|
||||
@ -208,7 +208,12 @@ void OpusTest::TestDtxEffect(bool dtx, int block_length_ms) {
|
||||
const int kCheckTimeMs = 4000;
|
||||
|
||||
#if defined(OPUS_FIXED_POINT)
|
||||
const uint16_t kOutputValueBound = 20;
|
||||
// Fixed-point Opus generates a random (comfort) noise, which has a less
|
||||
// predictable value bound than its floating-point Opus. This value depends on
|
||||
// input signal, and the time window for checking the output values (between
|
||||
// |kCheckTimeMs| and |kRunTimeMs|).
|
||||
const uint16_t kOutputValueBound = 30;
|
||||
|
||||
#else
|
||||
const uint16_t kOutputValueBound = 2;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user