From 93d0ef5b2e7c8d7d6288eb1fe0c334e63643eb2e Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Fri, 16 Jun 2023 13:49:15 -0400 Subject: [PATCH] Making DRED encoder run for CELT too --- src/opus_encoder.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index f6d3bc58..9f9f3fe3 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1469,10 +1469,6 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ { silk_EncControlStruct dummy; silk_InitEncoder( silk_enc, st->arch, &dummy); -#ifdef ENABLE_NEURAL_FEC - /* Initialize DRED Encoder */ - dred_encoder_reset( &st->dred_encoder ); -#endif prefill=1; } @@ -1686,6 +1682,14 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ } #endif +#ifdef ENABLE_NEURAL_FEC + if ( st->dred_duration > 0 ) { + /* DRED Encoder */ + dred_compute_latents( &st->dred_encoder, &pcm_buf[total_buffer*st->channels], frame_size ); + } else { + st->dred_encoder.latents_buffer_fill = 0; + } +#endif /* SILK processing */ HB_gain = Q15ONE; @@ -1826,15 +1830,6 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ } } -#ifdef ENABLE_NEURAL_FEC - if ( st->dred_duration > 0 ) { - /* DRED Encoder */ - dred_compute_latents( &st->dred_encoder, &pcm_buf[total_buffer*st->channels], frame_size ); - } else { - st->dred_encoder.latents_buffer_fill = 0; - } -#endif - if (prefill) { opus_int32 zero=0; @@ -1905,13 +1900,6 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ celt_to_silk = 0; st->silk_bw_switch = 1; } - } else { -#ifdef ENABLE_NEURAL_FEC - /* If we're not in SILK mode, delete all the processed DRED. - TODO: Remove this if/when DRED gets encoded for CELT. */ - DREDEnc *dred = &st->dred_encoder; - dred->latents_buffer_fill = 0; -#endif } /* CELT processing */