ref: 9ed3c7c982d58988a891d8b12d79bd234bd0b806
parent: 5c24975c3a1e46439a37c1a8b16c10515c85d1da
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Sat Oct 14 22:45:28 EDT 2023
Rename ENABLE_NEURAL_FED to ENABLE_DRED Signed-off-by: Jean-Marc Valin <jmvalin@amazon.com>
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,9 +79,9 @@
option(OPUS_INSTALL_CMAKE_CONFIG_MODULE ${OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR} ON)
add_feature_info(OPUS_INSTALL_CMAKE_CONFIG_MODULE OPUS_INSTALL_CMAKE_CONFIG_MODULE ${OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR})
-set(OPUS_NEURAL_FEC_HELP_STR "enable neural FEC.")
-option(OPUS_NEURAL_FEC ${OPUS_NEURAL_FEC_HELP_STR} OFF)
-add_feature_info(OPUS_NEURAL_FEC OPUS_NEURAL_FEC ${OPUS_NEURAL_FEC_HELP_STR})
+set(OPUS_DRED_HELP_STR "enable DRED.")
+option(OPUS_DRED ${OPUS_DRED_HELP_STR} OFF)
+add_feature_info(OPUS_DRED OPUS_DRED ${OPUS_DRED_HELP_STR})
if(APPLE)
set(OPUS_BUILD_FRAMEWORK_HELP_STR "build Framework bundle for Apple systems.")
@@ -371,8 +371,8 @@
target_compile_definitions(opus PRIVATE DISABLE_FLOAT_API)
endif()
-if (OPUS_NEURAL_FEC)
- target_compile_definitions(opus PRIVATE ENABLE_NEURAL_FEC)
+if (OPUS_DRED)
+ target_compile_definitions(opus PRIVATE ENABLE_DRED)
if(NOT OPUS_DEEP_PLC)
target_compile_definitions(opus PRIVATE ENABLE_DEEP_PLC)
endif()
@@ -669,7 +669,7 @@
-DTEST_EXECUTABLE=$<TARGET_FILE:test_opus_extensions>
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake")
- if(OPUS_NEURAL_FEC)
+ if(OPUS_DRED)
add_executable(test_opus_dred ${test_opus_dred_sources})
target_include_directories(test_opus_dred
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
--- a/celt/celt.h
+++ b/celt/celt.h
@@ -152,7 +152,7 @@
int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data,
int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
,LPCNetPLCState *lpcnet
#endif
);
--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -107,7 +107,7 @@
celt_sig preemph_memD[2];
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
opus_int16 plc_pcm[PLC_UPDATE_SAMPLES];
int plc_fill;
float plc_preemphasis_mem;
@@ -548,7 +548,7 @@
} while (++c<CC);
}
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
#define SINC_ORDER 48
/* h=cos(pi/2*abs(sin([-24:24]/48*pi*23./24)).^2);
@@ -600,7 +600,7 @@
#endif
static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
,LPCNetPLCState *lpcnet
#endif
)
@@ -638,7 +638,7 @@
loss_duration = st->loss_duration;
start = st->start;
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
noise_based = start != 0 || (lpcnet->fec_fill_pos == 0 && (st->skip_plc || loss_duration >= 80));
#else
noise_based = loss_duration >= 40 || start != 0 || st->skip_plc;
@@ -715,7 +715,7 @@
if (loss_duration == 0)
{
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
update_plc_state(lpcnet, decode_mem, C);
#endif
st->last_pitch_index = pitch_index = celt_plc_pitch_search(decode_mem, C, st->arch);
@@ -908,7 +908,7 @@
} while (++c<C);
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
{
float overlap_mem;
int samples_needed16k;
@@ -979,7 +979,7 @@
int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data,
int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
,LPCNetPLCState *lpcnet
#endif
)
@@ -1100,7 +1100,7 @@
if (data == NULL || len<=1)
{
celt_decode_lost(st, N, LM
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
, lpcnet
#endif
);
@@ -1108,7 +1108,7 @@
RESTORE_STACK;
return frame_size/st->downsample;
}
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
else {
/* FIXME: This is a bit of a hack just to make sure opus_decode_native() knows we're no longer in PLC. */
if (lpcnet) lpcnet->blend = 0;
@@ -1362,7 +1362,7 @@
int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum)
{
return celt_decode_with_ec_dred(st, data, len, pcm, frame_size, dec, accum
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
, NULL
#endif
);
--- a/configure.ac
+++ b/configure.ac
@@ -162,12 +162,12 @@
AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes"])
-AC_ARG_ENABLE([neural-fec],
- [AS_HELP_STRING([--enable-neural-fec], [Use neural FEC for SILK])],,
- [enable_neural_fec=yes])
+AC_ARG_ENABLE([dred],
+ [AS_HELP_STRING([--enable-dred], [Use Deep REDundancy (DRED)])],,
+ [enable_dred=yes])
-AS_IF([test "$enable_neural_fec" = "yes"],[
- AC_DEFINE([ENABLE_NEURAL_FEC], [1], [Neural FEC])
+AS_IF([test "$enable_dred" = "yes"],[
+ AC_DEFINE([ENABLE_DRED], [1], [DRED])
])
AC_ARG_ENABLE([deep-plc],
--- a/silk/enc_API.c
+++ b/silk/enc_API.c
@@ -41,7 +41,7 @@
#include "main_FLP.h"
#endif
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
#include "dred_encoder.h"
#endif
--- a/silk/init_encoder.c
+++ b/silk/init_encoder.c
@@ -36,7 +36,7 @@
#include "tuning_parameters.h"
#include "cpu_support.h"
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
#include "dred_encoder.h"
#endif
--- a/silk/structs.h
+++ b/silk/structs.h
@@ -39,7 +39,7 @@
#include "lpcnet_private.h"
#endif
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
#include "dred_encoder.h"
#include "dred_decoder.h"
#endif
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -534,7 +534,7 @@
/* Decode CELT */
celt_ret = celt_decode_with_ec_dred(celt_dec, decode_fec ? NULL : data,
len, pcm, celt_frame_size, &dec, celt_accum
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
, &st->lpcnet
#endif
);
@@ -663,7 +663,7 @@
/* For FEC/PLC, frame_size has to be to have a multiple of 2.5 ms */
if ((decode_fec || len==0 || data==NULL) && frame_size%(st->Fs/400)!=0)
return OPUS_BAD_ARG;
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
if (dred != NULL && dred->process_stage == 2) {
int F10;
int features_per_frame;
@@ -1130,7 +1130,7 @@
opus_uint32 magic;
};
-#if defined(ENABLE_NEURAL_FEC) && (defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS))
+#if defined(ENABLE_DRED) && (defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS))
static void validate_dred_decoder(OpusDREDDecoder *st)
{
celt_assert(st->magic == 0xD8EDDEC0);
@@ -1150,7 +1150,7 @@
return sizeof(OpusDREDDecoder);
}
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
int dred_decoder_load_model(OpusDREDDecoder *dec, const unsigned char *data, int len)
{
WeightArray *list;
@@ -1164,7 +1164,7 @@
int opus_dred_decoder_init(OpusDREDDecoder *dec)
{
-#if defined(ENABLE_NEURAL_FEC) && !defined(USE_WEIGHTS_FILE)
+#if defined(ENABLE_DRED) && !defined(USE_WEIGHTS_FILE)
init_rdovaedec(&dec->model, rdovaedec_arrays);
#endif
dec->arch = opus_select_arch();
@@ -1203,7 +1203,7 @@
int opus_dred_decoder_ctl(OpusDREDDecoder *dred_dec, int request, ...)
{
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
int ret = OPUS_OK;
va_list ap;
@@ -1243,7 +1243,7 @@
#endif
}
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
static int dred_find_payload(const unsigned char *data, opus_int32 len, const unsigned char **payload)
{
const unsigned char *data0;
@@ -1307,7 +1307,7 @@
int opus_dred_get_size(void)
{
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
return sizeof(OpusDRED);
#else
return 0;
@@ -1316,7 +1316,7 @@
OpusDRED *opus_dred_alloc(int *error)
{
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
OpusDRED *dec;
dec = (OpusDRED *)opus_alloc(opus_dred_get_size());
if (dec == NULL)
@@ -1335,7 +1335,7 @@
void opus_dred_free(OpusDRED *dec)
{
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
free(dec);
#else
(void)dec;
@@ -1344,7 +1344,7 @@
int opus_dred_parse(OpusDREDDecoder *dred_dec, OpusDRED *dred, const unsigned char *data, opus_int32 len, opus_int32 max_dred_samples, opus_int32 sampling_rate, int defer_processing)
{
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
const unsigned char *payload;
opus_int32 payload_len;
VALIDATE_DRED_DECODER(dred_dec);
@@ -1378,7 +1378,7 @@
int opus_dred_process(OpusDREDDecoder *dred_dec, const OpusDRED *src, OpusDRED *dst)
{
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
if (dred_dec == NULL || src == NULL || dst == NULL || (src->process_stage != 1 && src->process_stage != 2))
return OPUS_BAD_ARG;
VALIDATE_DRED_DECODER(dred_dec);
@@ -1399,7 +1399,7 @@
int opus_decoder_dred_decode(OpusDecoder *st, const OpusDRED *dred, opus_int32 dred_offset, opus_int16 *pcm, opus_int32 frame_size)
{
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
VARDECL(float, out);
int ret, i;
ALLOC_STACK;
@@ -1433,7 +1433,7 @@
int opus_decoder_dred_decode_float(OpusDecoder *st, const OpusDRED *dred, opus_int32 dred_offset, float *pcm, opus_int32 frame_size)
{
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
if(frame_size<=0)
return OPUS_BAD_ARG;
return opus_decode_native(st, NULL, 0, pcm, frame_size, 0, 0, NULL, 0, dred, dred_offset);
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -67,7 +67,7 @@
int celt_enc_offset;
int silk_enc_offset;
silk_EncControlStruct silk_mode;
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
DREDEnc dred_encoder;
#endif
int application;
@@ -119,7 +119,7 @@
int nb_no_activity_ms_Q1;
opus_val32 peak_signal_energy;
#endif
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
int dred_duration;
#endif
int nonfinal_frame; /* current frame is not the final in a packet */
@@ -243,7 +243,7 @@
celt_encoder_ctl(celt_enc, CELT_SET_SIGNALLING(0));
celt_encoder_ctl(celt_enc, OPUS_SET_COMPLEXITY(st->silk_mode.complexity));
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
/* Initialize DRED Encoder */
dred_encoder_init( &st->dred_encoder, Fs, channels );
#endif
@@ -556,7 +556,7 @@
return st;
}
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
static opus_int32 compute_dred_bitrate(OpusEncoder *st, opus_int32 bitrate_bps, int frame_size)
{
float dred_frac;
@@ -1123,7 +1123,7 @@
int is_silence = 0;
#endif
int apply_padding;
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
opus_int32 dred_bitrate_bps;
#endif
opus_int activity = VAD_NO_DECISION;
@@ -1260,7 +1260,7 @@
/* Make sure we provide at least one byte to avoid failing. */
max_data_bytes = IMAX(1, cbrBytes);
}
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
/* Allocate some of the bits to DRED if needed. */
dred_bitrate_bps = compute_dred_bitrate(st, st->bitrate_bps, frame_size);
st->bitrate_bps -= dred_bitrate_bps;
@@ -1712,7 +1712,7 @@
}
#endif
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
if ( st->dred_duration > 0 ) {
/* DRED Encoder */
dred_compute_latents( &st->dred_encoder, &pcm_buf[total_buffer*st->channels], frame_size, total_buffer );
@@ -2060,7 +2060,7 @@
nb_compr_bytes = ret;
} else {
nb_compr_bytes = (max_data_bytes-1)-redundancy_bytes;
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
if (st->dred_duration > 0)
{
int max_celt_bytes;
@@ -2123,7 +2123,7 @@
celt_encoder_ctl(celt_enc, OPUS_SET_BITRATE(st->bitrate_bps));
}
}
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
/* When Using DRED CBR, we can actually make the CELT part VBR and have DRED pick up the slack. */
if (!st->use_vbr && st->dred_duration > 0)
{
@@ -2254,7 +2254,7 @@
/* Count ToC and redundancy */
ret += 1+redundancy_bytes;
apply_padding = !st->use_vbr;
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
if (st->dred_duration > 0) {
opus_extension_data extension;
unsigned char buf[DRED_MAX_DATA_SIZE];
@@ -2790,7 +2790,7 @@
celt_encoder_ctl(celt_enc, OPUS_GET_PHASE_INVERSION_DISABLED(value));
}
break;
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
case OPUS_SET_DRED_DURATION_REQUEST:
{
opus_int32 value = va_arg(ap, opus_int32);
@@ -2828,7 +2828,7 @@
celt_encoder_ctl(celt_enc, OPUS_RESET_STATE);
silk_InitEncoder( silk_enc, st->arch, &dummy );
-#ifdef ENABLE_NEURAL_FEC
+#ifdef ENABLE_DRED
/* Initialize DRED Encoder */
dred_encoder_reset( &st->dred_encoder );
#endif
--
⑨