diff --git a/CMakeLists.txt b/CMakeLists.txt index a0dd3479d33f15b3eab12ded21289498ae573507..450275baed9e9e6f98fb9ad54193c2b9edda5ced 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,9 +79,9 @@ set(OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR "install CMake package config modu 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 @@ if(NOT OPUS_ENABLE_FLOAT_API) 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 @@ if(BUILD_TESTING AND NOT BUILD_SHARED_LIBS) -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}) diff --git a/celt/celt.h b/celt/celt.h index 2f5197bbeb97a58bbb5be7e73dd662c04aae07cb..b5bafa37370b68c315c096a15a18367406f104e0 100644 --- a/celt/celt.h +++ b/celt/celt.h @@ -152,7 +152,7 @@ int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels); 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 ); diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c index d83d68a5bb65318d782366a141ff6c29ee2a52fd..7508a245c453f99116b19e21457a852539c62ac7 100644 --- a/celt/celt_decoder.c +++ b/celt/celt_decoder.c @@ -107,7 +107,7 @@ struct OpusCustomDecoder { 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 @@ static void prefilter_and_fold(CELTDecoder * OPUS_RESTRICT st, int N) } 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 @@ void update_plc_state(LPCNetPLCState *lpcnet, celt_sig *decode_mem[2], int CC) #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 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM 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 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM 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 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM } while (++c<C); -#ifdef ENABLE_NEURAL_FEC +#ifdef ENABLE_DRED { float overlap_mem; int samples_needed16k; @@ -979,7 +979,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM 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 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char if (data == NULL || len<=1) { celt_decode_lost(st, N, LM -#ifdef ENABLE_NEURAL_FEC +#ifdef ENABLE_DRED , lpcnet #endif ); @@ -1108,7 +1108,7 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char 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 celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat 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 ); diff --git a/configure.ac b/configure.ac index ee5fe19ecfffe40b532509afe862e6943bb8cd90..0634e6d0fb4ced8e16e80f4ffa44cfd9c86669de 100644 --- a/configure.ac +++ b/configure.ac @@ -162,12 +162,12 @@ AS_IF([test "$enable_custom_modes" = "yes"],[ 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], diff --git a/silk/enc_API.c b/silk/enc_API.c index ff3070a1d7dfa6d4d48f344e3a2d29ad584e8484..369caddd9859b41c669d5720254ee608e7a04b9e 100644 --- a/silk/enc_API.c +++ b/silk/enc_API.c @@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "main_FLP.h" #endif -#ifdef ENABLE_NEURAL_FEC +#ifdef ENABLE_DRED #include "dred_encoder.h" #endif diff --git a/silk/init_encoder.c b/silk/init_encoder.c index 78b5ee88b4ae80f14d9779ced3c3f53ff0a00f2e..10d41287fed4e4703473902f1225270166cd99ca 100644 --- a/silk/init_encoder.c +++ b/silk/init_encoder.c @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "tuning_parameters.h" #include "cpu_support.h" -#ifdef ENABLE_NEURAL_FEC +#ifdef ENABLE_DRED #include "dred_encoder.h" #endif diff --git a/silk/structs.h b/silk/structs.h index cc85c1cac54191ea92efa47e9d10575e3a24269c..22e79f701a779f2b004c78b8c63e76d87099df82 100644 --- a/silk/structs.h +++ b/silk/structs.h @@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "lpcnet_private.h" #endif -#ifdef ENABLE_NEURAL_FEC +#ifdef ENABLE_DRED #include "dred_encoder.h" #include "dred_decoder.h" #endif diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 80a8c56764df7232551a3cf6702788f13b78b165..1f098e82c475c039436575f4ade819ec67af174a 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -534,7 +534,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, /* 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 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, /* 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 @@ struct OpusDREDDecoder { 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 @@ int opus_dred_decoder_get_size(void) 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 dred_decoder_load_model(OpusDREDDecoder *dec, const unsigned char *data, int 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 @@ void opus_dred_decoder_destroy(OpusDREDDecoder *dec) 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 @@ bad_arg: #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 @@ static int dred_find_payload(const unsigned char *data, opus_int32 len, const un int opus_dred_get_size(void) { -#ifdef ENABLE_NEURAL_FEC +#ifdef ENABLE_DRED return sizeof(OpusDRED); #else return 0; @@ -1316,7 +1316,7 @@ int opus_dred_get_size(void) 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 @@ OpusDRED *opus_dred_alloc(int *error) void opus_dred_free(OpusDRED *dec) { -#ifdef ENABLE_NEURAL_FEC +#ifdef ENABLE_DRED free(dec); #else (void)dec; @@ -1344,7 +1344,7 @@ void opus_dred_free(OpusDRED *dec) 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_parse(OpusDREDDecoder *dred_dec, OpusDRED *dred, const unsigned ch 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_dred_process(OpusDREDDecoder *dred_dec, const OpusDRED *src, OpusDRED * 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(OpusDecoder *st, const OpusDRED *dred, opus_int32 d 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); diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 7291c8143dda06d0f9abff9f19f3e64a095e4bd0..5ed4b1870060c85c898c7aef574e421bdf32ff54 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -67,7 +67,7 @@ struct OpusEncoder { 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 @@ struct OpusEncoder { 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 @@ int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int applicat 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 @@ OpusEncoder *opus_encoder_create(opus_int32 Fs, int channels, int application, i 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 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ 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 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ /* 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 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ } #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 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ 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 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ 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 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ /* 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 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...) 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 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...) 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