From afea46e9d795bd08ee7f82fb65a9ff4a7d842b66 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Sun, 7 Apr 2019 23:27:57 -0700 Subject: Correctly enable/disable SILK DTX with forced mode --- src/opus_encoder.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/opus_encoder.c b/src/opus_encoder.c index ab9e3e89..2768aa37 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1336,6 +1336,14 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ equiv_rate = compute_equiv_rate(st->bitrate_bps, st->stream_channels, st->Fs/frame_size, st->use_vbr, 0, st->silk_mode.complexity, st->silk_mode.packetLossPercentage); + /* Allow SILK DTX if DTX is enabled but the generalized DTX cannot be used, + e.g. because of the complexity setting or sample rate. */ +#ifndef DISABLE_FLOAT_API + st->silk_mode.useDTX = st->use_dtx && !(analysis_info.valid || is_silence); +#else + st->silk_mode.useDTX = st->use_dtx; +#endif + /* Mode selection depending on application and signal type */ if (st->application == OPUS_APPLICATION_RESTRICTED_LOWDELAY) { @@ -1384,13 +1392,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ if (st->silk_mode.useInBandFEC && st->silk_mode.packetLossPercentage > (128-voice_est)>>4) st->mode = MODE_SILK_ONLY; /* When encoding voice and DTX is enabled but the generalized DTX cannot be used, - because of complexity and sampling frequency settings, switch to SILK DTX and - set the encoder to SILK mode */ -#ifndef DISABLE_FLOAT_API - st->silk_mode.useDTX = st->use_dtx && !(analysis_info.valid || is_silence); -#else - st->silk_mode.useDTX = st->use_dtx; -#endif + use SILK in order to make use of its DTX. */ if (st->silk_mode.useDTX && voice_est > 100) st->mode = MODE_SILK_ONLY; #endif -- cgit v1.2.3