shithub: opus

Download patch

ref: d7ce091b1c459eafcbbb43a3e15c2590f5657b24
parent: e0c6eae8cc789b1d80babe5219d505fbf9d91a88
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Fri May 19 10:14:40 EDT 2023

Don't run the DRED encoder unless DRED is enabled

--- a/silk/control.h
+++ b/silk/control.h
@@ -77,6 +77,9 @@
     /* I:   Flag to enable in-band Forward Error Correction (FEC); 0/1                      */
     opus_int useInBandFEC;
 
+    /* I:   Flag to enable in-band Deep REDundancy (DRED); 0/1                              */
+    opus_int useDRED;
+
     /* I:   Flag to actually code in-band Forward Error Correction (FEC) in the current packet; 0/1 */
     opus_int LBRR_coded;
 
--- a/silk/enc_API.c
+++ b/silk/enc_API.c
@@ -469,8 +469,12 @@
             silk_encode_do_VAD_Fxx( &psEnc->state_Fxx[ 0 ], activity );
 
 #ifdef ENABLE_NEURAL_FEC
-            /* DRED Encoder */
-            dred_process_silk_frame( &psEnc->state_Fxx[ 0 ].sCmn.dred_encoder, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[0] );
+            if ( encControl->useDRED ) {
+                /* DRED Encoder */
+                dred_process_silk_frame( &psEnc->state_Fxx[ 0 ].sCmn.dred_encoder, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[0] );
+            } else {
+                psEnc->state_Fxx[ 0 ].sCmn.dred_encoder.latents_buffer_fill = 0;
+            }
 #endif
 
             /* Encode */
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -227,6 +227,7 @@
     st->silk_mode.packetLossPercentage      = 0;
     st->silk_mode.complexity                = 9;
     st->silk_mode.useInBandFEC              = 0;
+    st->silk_mode.useDRED                   = 0;
     st->silk_mode.useDTX                    = 0;
     st->silk_mode.useCBR                    = 0;
     st->silk_mode.reducedDependency         = 0;
@@ -2733,6 +2734,7 @@
                goto bad_arg;
             }
             st->dred_duration = value;
+            st->silk_mode.useDRED = !!value;
         }
         break;
         case OPUS_GET_DRED_DURATION_REQUEST:
--